New: Send additional information with Webhook and Custom Scripts

(cherry picked from commit e5d6e569cf05cbe431e7ffa98569017d5243d848)
pull/1650/head
Devin Buhl 2 years ago committed by Bogdan
parent 202836110e
commit a753f721d1

@ -6,6 +6,7 @@ using NLog;
using NzbDrone.Common.Disk; using NzbDrone.Common.Disk;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Common.Processes; using NzbDrone.Common.Processes;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.HealthCheck; using NzbDrone.Core.HealthCheck;
using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation; using NzbDrone.Core.Validation;
@ -14,12 +15,20 @@ namespace NzbDrone.Core.Notifications.CustomScript
{ {
public class CustomScript : NotificationBase<CustomScriptSettings> public class CustomScript : NotificationBase<CustomScriptSettings>
{ {
private readonly IConfigFileProvider _configFileProvider;
private readonly IConfigService _configService;
private readonly IDiskProvider _diskProvider; private readonly IDiskProvider _diskProvider;
private readonly IProcessProvider _processProvider; private readonly IProcessProvider _processProvider;
private readonly Logger _logger; private readonly Logger _logger;
public CustomScript(IDiskProvider diskProvider, IProcessProvider processProvider, Logger logger) public CustomScript(IConfigFileProvider configFileProvider,
IConfigService configService,
IDiskProvider diskProvider,
IProcessProvider processProvider,
Logger logger)
{ {
_configFileProvider = configFileProvider;
_configService = configService;
_diskProvider = diskProvider; _diskProvider = diskProvider;
_processProvider = processProvider; _processProvider = processProvider;
_logger = logger; _logger = logger;
@ -36,6 +45,8 @@ namespace NzbDrone.Core.Notifications.CustomScript
var environmentVariables = new StringDictionary(); var environmentVariables = new StringDictionary();
environmentVariables.Add("Prowlarr_EventType", "HealthIssue"); environmentVariables.Add("Prowlarr_EventType", "HealthIssue");
environmentVariables.Add("Prowlarr_InstanceName", _configFileProvider.InstanceName);
environmentVariables.Add("Prowlarr_ApplicationUrl", _configService.ApplicationUrl);
environmentVariables.Add("Prowlarr_Health_Issue_Level", Enum.GetName(typeof(HealthCheckResult), healthCheck.Type)); environmentVariables.Add("Prowlarr_Health_Issue_Level", Enum.GetName(typeof(HealthCheckResult), healthCheck.Type));
environmentVariables.Add("Prowlarr_Health_Issue_Message", healthCheck.Message); environmentVariables.Add("Prowlarr_Health_Issue_Message", healthCheck.Message);
environmentVariables.Add("Prowlarr_Health_Issue_Type", healthCheck.Source.Name); environmentVariables.Add("Prowlarr_Health_Issue_Type", healthCheck.Source.Name);
@ -49,6 +60,8 @@ namespace NzbDrone.Core.Notifications.CustomScript
var environmentVariables = new StringDictionary(); var environmentVariables = new StringDictionary();
environmentVariables.Add("Prowlarr_EventType", "ApplicationUpdate"); environmentVariables.Add("Prowlarr_EventType", "ApplicationUpdate");
environmentVariables.Add("Prowlarr_InstanceName", _configFileProvider.InstanceName);
environmentVariables.Add("Prowlarr_ApplicationUrl", _configService.ApplicationUrl);
environmentVariables.Add("Prowlarr_Update_Message", updateMessage.Message); environmentVariables.Add("Prowlarr_Update_Message", updateMessage.Message);
environmentVariables.Add("Prowlarr_Update_NewVersion", updateMessage.NewVersion.ToString()); environmentVariables.Add("Prowlarr_Update_NewVersion", updateMessage.NewVersion.ToString());
environmentVariables.Add("Prowlarr_Update_PreviousVersion", updateMessage.PreviousVersion.ToString()); environmentVariables.Add("Prowlarr_Update_PreviousVersion", updateMessage.PreviousVersion.ToString());
@ -79,6 +92,8 @@ namespace NzbDrone.Core.Notifications.CustomScript
{ {
var environmentVariables = new StringDictionary(); var environmentVariables = new StringDictionary();
environmentVariables.Add("Prowlarr_EventType", "Test"); environmentVariables.Add("Prowlarr_EventType", "Test");
environmentVariables.Add("Prowlarr_InstanceName", _configFileProvider.InstanceName);
environmentVariables.Add("Prowlarr_ApplicationUrl", _configService.ApplicationUrl);
var processOutput = ExecuteScript(environmentVariables); var processOutput = ExecuteScript(environmentVariables);

@ -11,8 +11,8 @@ namespace NzbDrone.Core.Notifications.Notifiarr
{ {
private readonly INotifiarrProxy _proxy; private readonly INotifiarrProxy _proxy;
public Notifiarr(INotifiarrProxy proxy, IConfigFileProvider configFileProvider) public Notifiarr(INotifiarrProxy proxy, IConfigFileProvider configFileProvider, IConfigService configService)
: base(configFileProvider) : base(configFileProvider, configService)
{ {
_proxy = proxy; _proxy = proxy;
} }

@ -10,8 +10,8 @@ namespace NzbDrone.Core.Notifications.Webhook
{ {
private readonly IWebhookProxy _proxy; private readonly IWebhookProxy _proxy;
public Webhook(IWebhookProxy proxy, IConfigFileProvider configFileProvider) public Webhook(IWebhookProxy proxy, IConfigFileProvider configFileProvider, IConfigService configService)
: base(configFileProvider) : base(configFileProvider, configService)
{ {
_proxy = proxy; _proxy = proxy;
} }

@ -7,11 +7,12 @@ namespace NzbDrone.Core.Notifications.Webhook
where TSettings : IProviderConfig, new() where TSettings : IProviderConfig, new()
{ {
private readonly IConfigFileProvider _configFileProvider; private readonly IConfigFileProvider _configFileProvider;
private readonly IConfigService _configService;
protected WebhookBase(IConfigFileProvider configFileProvider) protected WebhookBase(IConfigFileProvider configFileProvider, IConfigService configService)
: base()
{ {
_configFileProvider = configFileProvider; _configFileProvider = configFileProvider;
_configService = configService;
} }
public WebhookGrabPayload BuildGrabPayload(GrabMessage message) public WebhookGrabPayload BuildGrabPayload(GrabMessage message)
@ -20,6 +21,7 @@ namespace NzbDrone.Core.Notifications.Webhook
{ {
EventType = WebhookEventType.Grab, EventType = WebhookEventType.Grab,
InstanceName = _configFileProvider.InstanceName, InstanceName = _configFileProvider.InstanceName,
ApplicationUrl = _configService.ApplicationUrl,
Release = new WebhookRelease(message.Release), Release = new WebhookRelease(message.Release),
Trigger = message.GrabTrigger, Trigger = message.GrabTrigger,
Source = message.Source, Source = message.Source,
@ -36,6 +38,7 @@ namespace NzbDrone.Core.Notifications.Webhook
{ {
EventType = WebhookEventType.Health, EventType = WebhookEventType.Health,
InstanceName = _configFileProvider.InstanceName, InstanceName = _configFileProvider.InstanceName,
ApplicationUrl = _configService.ApplicationUrl,
Level = healthCheck.Type, Level = healthCheck.Type,
Message = healthCheck.Message, Message = healthCheck.Message,
Type = healthCheck.Source.Name, Type = healthCheck.Source.Name,
@ -49,6 +52,7 @@ namespace NzbDrone.Core.Notifications.Webhook
{ {
EventType = WebhookEventType.ApplicationUpdate, EventType = WebhookEventType.ApplicationUpdate,
InstanceName = _configFileProvider.InstanceName, InstanceName = _configFileProvider.InstanceName,
ApplicationUrl = _configService.ApplicationUrl,
Message = updateMessage.Message, Message = updateMessage.Message,
PreviousVersion = updateMessage.PreviousVersion.ToString(), PreviousVersion = updateMessage.PreviousVersion.ToString(),
NewVersion = updateMessage.NewVersion.ToString() NewVersion = updateMessage.NewVersion.ToString()
@ -60,7 +64,8 @@ namespace NzbDrone.Core.Notifications.Webhook
return new WebhookPayload return new WebhookPayload
{ {
EventType = WebhookEventType.Test, EventType = WebhookEventType.Test,
InstanceName = _configFileProvider.InstanceName InstanceName = _configFileProvider.InstanceName,
ApplicationUrl = _configService.ApplicationUrl,
}; };
} }
} }

@ -4,5 +4,6 @@ namespace NzbDrone.Core.Notifications.Webhook
{ {
public WebhookEventType EventType { get; set; } public WebhookEventType EventType { get; set; }
public string InstanceName { get; set; } public string InstanceName { get; set; }
public string ApplicationUrl { get; set; }
} }
} }

Loading…
Cancel
Save