mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Inherit trigger from pushed command models
(cherry picked from commit 0bc4903954b955fce0c368ef7fd2a6f3761d6a93)
This commit is contained in:
@@ -105,6 +105,8 @@ namespace NzbDrone.Core.Messaging.Commands
|
|||||||
_logger.Trace("Publishing {0}", command.Name);
|
_logger.Trace("Publishing {0}", command.Name);
|
||||||
_logger.Trace("Checking if command is queued or started: {0}", command.Name);
|
_logger.Trace("Checking if command is queued or started: {0}", command.Name);
|
||||||
|
|
||||||
|
command.Trigger = trigger;
|
||||||
|
|
||||||
lock (_commandQueue)
|
lock (_commandQueue)
|
||||||
{
|
{
|
||||||
var existingCommands = QueuedOrStarted(command.Name);
|
var existingCommands = QueuedOrStarted(command.Name);
|
||||||
@@ -141,7 +143,6 @@ namespace NzbDrone.Core.Messaging.Commands
|
|||||||
var command = GetCommand(commandName);
|
var command = GetCommand(commandName);
|
||||||
command.LastExecutionTime = lastExecutionTime;
|
command.LastExecutionTime = lastExecutionTime;
|
||||||
command.LastStartTime = lastStartTime;
|
command.LastStartTime = lastStartTime;
|
||||||
command.Trigger = trigger;
|
|
||||||
|
|
||||||
return Push(command, priority, trigger);
|
return Push(command, priority, trigger);
|
||||||
}
|
}
|
||||||
@@ -232,13 +233,13 @@ namespace NzbDrone.Core.Messaging.Commands
|
|||||||
_repo.Trim();
|
_repo.Trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
private dynamic GetCommand(string commandName)
|
private Command GetCommand(string commandName)
|
||||||
{
|
{
|
||||||
commandName = commandName.Split('.').Last();
|
commandName = commandName.Split('.').Last();
|
||||||
var commands = _knownTypes.GetImplementations(typeof(Command));
|
var commands = _knownTypes.GetImplementations(typeof(Command));
|
||||||
var commandType = commands.Single(c => c.Name.Equals(commandName, StringComparison.InvariantCultureIgnoreCase));
|
var commandType = commands.Single(c => c.Name.Equals(commandName, StringComparison.InvariantCultureIgnoreCase));
|
||||||
|
|
||||||
return Json.Deserialize("{}", commandType);
|
return Json.Deserialize("{}", commandType) as Command;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update(CommandModel command, CommandStatus status, string message)
|
private void Update(CommandModel command, CommandStatus status, string message)
|
||||||
|
@@ -61,9 +61,8 @@ namespace Prowlarr.Api.V1.Commands
|
|||||||
using var reader = new StreamReader(Request.Body);
|
using var reader = new StreamReader(Request.Body);
|
||||||
var body = reader.ReadToEnd();
|
var body = reader.ReadToEnd();
|
||||||
|
|
||||||
dynamic command = STJson.Deserialize(body, commandType);
|
var command = STJson.Deserialize(body, commandType) as Command;
|
||||||
|
|
||||||
command.Trigger = CommandTrigger.Manual;
|
|
||||||
command.SuppressMessages = !command.SendUpdatesToClient;
|
command.SuppressMessages = !command.SendUpdatesToClient;
|
||||||
command.SendUpdatesToClient = true;
|
command.SendUpdatesToClient = true;
|
||||||
command.ClientUserAgent = Request.Headers["User-Agent"];
|
command.ClientUserAgent = Request.Headers["User-Agent"];
|
||||||
|
Reference in New Issue
Block a user