mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-26 20:11:49 +02:00
Commands are stored in memory and prevents duplicate jobs
This commit is contained in:
@@ -4,6 +4,7 @@ using Nancy;
|
||||
using NzbDrone.Api.Extensions;
|
||||
using NzbDrone.Common.Composition;
|
||||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Common.Messaging.Manager;
|
||||
|
||||
namespace NzbDrone.Api.Commands
|
||||
{
|
||||
@@ -11,14 +12,16 @@ namespace NzbDrone.Api.Commands
|
||||
{
|
||||
private readonly IMessageAggregator _messageAggregator;
|
||||
private readonly IContainer _container;
|
||||
private readonly IManageCommands _commandManager;
|
||||
|
||||
public CommandModule(IMessageAggregator messageAggregator, IContainer container)
|
||||
public CommandModule(IMessageAggregator messageAggregator, IContainer container, IManageCommands commandManager)
|
||||
{
|
||||
_messageAggregator = messageAggregator;
|
||||
_container = container;
|
||||
_commandManager = commandManager;
|
||||
|
||||
Post["/"] = x => RunCommand(ReadResourceFromRequest());
|
||||
|
||||
Get["/"] = x => GetAllCommands();
|
||||
}
|
||||
|
||||
private Response RunCommand(CommandResource resource)
|
||||
@@ -33,5 +36,10 @@ namespace NzbDrone.Api.Commands
|
||||
|
||||
return resource.AsResponse(HttpStatusCode.Created);
|
||||
}
|
||||
|
||||
private Response GetAllCommands()
|
||||
{
|
||||
return _commandManager.Items.AsResponse();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user