1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-17 21:26:13 -04:00

New: Ability to set command priority when starting command via API

This commit is contained in:
Mark McDowall
2026-01-11 10:49:42 -08:00
parent 28300ffb2b
commit 399ca1661f
4 changed files with 6 additions and 8 deletions

View File

@@ -11,6 +11,7 @@ export type CommandStatus =
| 'orphaned';
export type CommandResult = 'unknown' | 'successful' | 'unsuccessful';
export type CommandPriority = 'low' | 'normal' | 'high';
// Base command body with common properties
export interface BaseCommandBody {
@@ -85,6 +86,7 @@ export type CommandBody =
// Simplified interface for creating new commands
export interface NewCommandBody {
name: string;
priority?: CommandPriority;
seriesId?: number;
seriesIds?: number[];
seasonNumber?: number;
@@ -126,7 +128,7 @@ interface Command extends ModelBase {
commandName: string;
message: string;
body: CommandBody;
priority: string;
priority: CommandPriority;
status: CommandStatus;
result: CommandResult;
queued: string;

View File

@@ -598,6 +598,7 @@ function InteractiveImportModalContentInner(
name: CommandNames.ManualImport,
files,
importMode: finalImportMode,
priority: 'high',
});
shouldClose = true;

View File

@@ -2,7 +2,6 @@ using Microsoft.AspNetCore.Mvc;
using NzbDrone.Common.Composition;
using NzbDrone.Common.Serializer;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.MediaFiles.EpisodeImport.Manual;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.ProgressMessaging;
@@ -58,10 +57,6 @@ public class CommandController : RestControllerWithSignalR<CommandResource, Comm
using (var reader = new StreamReader(Request.Body))
{
var body = reader.ReadToEnd();
var priority = commandType == typeof(ManualImportCommand)
? CommandPriority.High
: CommandPriority.Normal;
var command = STJson.Deserialize(body, commandType) as Command;
if (command == null)
@@ -73,7 +68,7 @@ public class CommandController : RestControllerWithSignalR<CommandResource, Comm
command.SendUpdatesToClient = true;
command.ClientUserAgent = Request.Headers["UserAgent"];
var trackedCommand = _commandQueueManager.Push(command, priority, CommandTrigger.Manual);
var trackedCommand = _commandQueueManager.Push(command, commandResource.Priority, CommandTrigger.Manual);
return Created(trackedCommand.Id);
}

View File

@@ -12,7 +12,7 @@ public class CommandResource : RestResource
public string? CommandName { get; set; }
public string? Message { get; set; }
public Command? Body { get; set; }
public CommandPriority Priority { get; set; }
public CommandPriority Priority { get; set; } = CommandPriority.Normal;
public CommandStatus Status { get; set; }
public CommandResult Result { get; set; }
public DateTime Queued { get; set; }