mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-14 11:23:42 +02:00
Show User Agent in System->Tasks for externally triggered commands
This commit is contained in:
parent
91fe47ef31
commit
fe8f319f7b
@ -10,6 +10,15 @@
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.commandName {
|
||||
display: inline-block;
|
||||
min-width: 220px;
|
||||
}
|
||||
|
||||
.userAgent {
|
||||
color: #b0b0b0;
|
||||
}
|
||||
|
||||
.queued,
|
||||
.started,
|
||||
.ended {
|
||||
|
@ -156,6 +156,7 @@ class QueuedTaskRow extends Component {
|
||||
status,
|
||||
duration,
|
||||
message,
|
||||
clientUserAgent,
|
||||
longDateFormat,
|
||||
timeFormat,
|
||||
onCancelPress
|
||||
@ -191,7 +192,17 @@ class QueuedTaskRow extends Component {
|
||||
</span>
|
||||
</TableRowCell>
|
||||
|
||||
<TableRowCell>{commandName}</TableRowCell>
|
||||
<TableRowCell>
|
||||
<span className={styles.commandName}>
|
||||
{commandName}
|
||||
</span>
|
||||
{
|
||||
clientUserAgent &&
|
||||
<span className={styles.userAgent} title="User-Agent provided by the app that called the API">
|
||||
from: {clientUserAgent}
|
||||
</span>
|
||||
}
|
||||
</TableRowCell>
|
||||
|
||||
<TableRowCell
|
||||
className={styles.queued}
|
||||
|
@ -4,6 +4,7 @@
|
||||
using Newtonsoft.Json;
|
||||
using Sonarr.Http.REST;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Common.Http;
|
||||
|
||||
namespace NzbDrone.Api.Commands
|
||||
{
|
||||
@ -21,6 +22,8 @@ public class CommandResource : RestResource
|
||||
public string Exception { get; set; }
|
||||
public CommandTrigger Trigger { get; set; }
|
||||
|
||||
public string ClientUserAgent { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public string CompletionMessage { get; set; }
|
||||
|
||||
@ -117,6 +120,8 @@ public static CommandResource ToResource(this CommandModel model)
|
||||
Exception = model.Exception,
|
||||
Trigger = model.Trigger,
|
||||
|
||||
ClientUserAgent = UserAgentParser.SimplifyUserAgent(model.Body.ClientUserAgent),
|
||||
|
||||
CompletionMessage = model.Body.CompletionMessage,
|
||||
LastExecutionTime = model.Body.LastExecutionTime
|
||||
};
|
||||
|
21
src/NzbDrone.Common/Http/UserAgentParser.cs
Normal file
21
src/NzbDrone.Common/Http/UserAgentParser.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NzbDrone.Common.Http
|
||||
{
|
||||
public static class UserAgentParser
|
||||
{
|
||||
public static string SimplifyUserAgent(string userAgent)
|
||||
{
|
||||
if (userAgent == null || userAgent.StartsWith("Mozilla/5.0"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return userAgent;
|
||||
}
|
||||
}
|
||||
}
|
@ -29,6 +29,8 @@ public virtual bool SendUpdatesToClient
|
||||
public CommandTrigger Trigger { get; set; }
|
||||
public bool SuppressMessages { get; set; }
|
||||
|
||||
public string ClientUserAgent { get; set; }
|
||||
|
||||
public Command()
|
||||
{
|
||||
Name = GetType().Name.Replace("Command", "");
|
||||
|
@ -57,6 +57,8 @@ private int StartCommand(CommandResource commandResource)
|
||||
command.SuppressMessages = !command.SendUpdatesToClient;
|
||||
command.SendUpdatesToClient = true;
|
||||
|
||||
command.ClientUserAgent = Request.Headers.UserAgent;
|
||||
|
||||
var trackedCommand = _commandQueueManager.Push(command, CommandPriority.Normal, CommandTrigger.Manual);
|
||||
return trackedCommand.Id;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using Sonarr.Http.REST;
|
||||
|
||||
@ -23,6 +24,8 @@ public class CommandResource : RestResource
|
||||
public string Exception { get; set; }
|
||||
public CommandTrigger Trigger { get; set; }
|
||||
|
||||
public string ClientUserAgent { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public string CompletionMessage { get; set; }
|
||||
|
||||
@ -89,6 +92,8 @@ public static CommandResource ToResource(this CommandModel model)
|
||||
Exception = model.Exception,
|
||||
Trigger = model.Trigger,
|
||||
|
||||
ClientUserAgent = UserAgentParser.SimplifyUserAgent(model.Body.ClientUserAgent),
|
||||
|
||||
CompletionMessage = model.Body.CompletionMessage,
|
||||
LastExecutionTime = model.Body.LastExecutionTime
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user