diff --git a/frontend/src/Settings/Notifications/Notifications/Notification.js b/frontend/src/Settings/Notifications/Notifications/Notification.js index e356024c4..e4a2847d9 100644 --- a/frontend/src/Settings/Notifications/Notifications/Notification.js +++ b/frontend/src/Settings/Notifications/Notifications/Notification.js @@ -40,7 +40,7 @@ class Notification extends Component { }); }; - onDeleteNotificationModalClose= () => { + onDeleteNotificationModalClose = () => { this.setState({ isDeleteNotificationModalOpen: false }); }; @@ -61,12 +61,14 @@ class Notification extends Component { onRename, onDelete, onHealthIssue, + onApplicationUpdate, supportsOnGrab, supportsOnDownload, supportsOnUpgrade, supportsOnRename, supportsOnDelete, - supportsOnHealthIssue + supportsOnHealthIssue, + supportsOnApplicationUpdate } = this.props; return ( @@ -82,53 +84,62 @@ class Notification extends Component { { supportsOnGrab && onGrab && } { supportsOnDelete && onDelete && } { supportsOnDownload && onDownload && } { supportsOnUpgrade && onDownload && onUpgrade && } { supportsOnRename && onRename && } { supportsOnHealthIssue && onHealthIssue && } { - !onGrab && !onDownload && !onRename && !onHealthIssue && !onDelete && + supportsOnApplicationUpdate && onApplicationUpdate ? + : + null + } + + { + !onGrab && !onDownload && !onRename && !onHealthIssue && !onDelete && !onApplicationUpdate ? + {translate('Disabled')} + : + null } } + +
+ +
diff --git a/frontend/src/Store/Actions/Settings/notifications.js b/frontend/src/Store/Actions/Settings/notifications.js index 062fe4d9e..c9c86a2a8 100644 --- a/frontend/src/Store/Actions/Settings/notifications.js +++ b/frontend/src/Store/Actions/Settings/notifications.js @@ -106,6 +106,7 @@ export default { selectedSchema.onDownload = selectedSchema.supportsOnDownload; selectedSchema.onUpgrade = selectedSchema.supportsOnUpgrade; selectedSchema.onRename = selectedSchema.supportsOnRename; + selectedSchema.onApplicationUpdate = selectedSchema.supportsOnApplicationUpdate; return selectedSchema; }); diff --git a/src/NzbDrone.Core.Test/NotificationTests/NotificationBaseFixture.cs b/src/NzbDrone.Core.Test/NotificationTests/NotificationBaseFixture.cs new file mode 100644 index 000000000..35fe385e8 --- /dev/null +++ b/src/NzbDrone.Core.Test/NotificationTests/NotificationBaseFixture.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using FluentAssertions; +using FluentValidation.Results; +using NUnit.Framework; +using NzbDrone.Core.Notifications; +using NzbDrone.Core.ThingiProvider; +using NzbDrone.Core.Validation; +using NzbDrone.Test.Common; + +namespace NzbDrone.Core.Test.NotificationTests +{ + [TestFixture] + public class NotificationBaseFixture : TestBase + { + private class TestSetting : IProviderConfig + { + public NzbDroneValidationResult Validate() + { + return new NzbDroneValidationResult(); + } + } + + private class TestNotificationWithApplicationUpdate : NotificationBase + { + public override string Name => "TestNotification"; + public override string Link => ""; + + public override ValidationResult Test() + { + throw new NotImplementedException(); + } + + public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage) + { + TestLogger.Info("OnApplicationUpdate was called"); + } + } + + private class TestNotificationWithAllEvents : NotificationBase + { + public override string Name => "TestNotification"; + public override string Link => ""; + + public override ValidationResult Test() + { + throw new NotImplementedException(); + } + + public override void OnHealthIssue(NzbDrone.Core.HealthCheck.HealthCheck artist) + { + TestLogger.Info("OnHealthIssue was called"); + } + + public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage) + { + TestLogger.Info("OnApplicationUpdate was called"); + } + } + + private class TestNotificationWithNoEvents : NotificationBase + { + public override string Name => "TestNotification"; + public override string Link => ""; + + public override ValidationResult Test() + { + throw new NotImplementedException(); + } + } + + [Test] + public void should_support_all_if_implemented() + { + var notification = new TestNotificationWithAllEvents(); + + notification.SupportsOnHealthIssue.Should().BeTrue(); + notification.SupportsOnApplicationUpdate.Should().BeTrue(); + } + + [Test] + public void should_support_none_if_none_are_implemented() + { + var notification = new TestNotificationWithNoEvents(); + + notification.SupportsOnHealthIssue.Should().BeFalse(); + notification.SupportsOnApplicationUpdate.Should().BeFalse(); + } + } +} diff --git a/src/NzbDrone.Core/Datastore/Migration/014_add_on_update_to_notifications.cs b/src/NzbDrone.Core/Datastore/Migration/014_add_on_update_to_notifications.cs new file mode 100644 index 000000000..3fc05561a --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/014_add_on_update_to_notifications.cs @@ -0,0 +1,14 @@ +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(014)] + public class add_on_update_to_notifications : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Alter.Table("Notifications").AddColumn("OnApplicationUpdate").AsBoolean().WithDefaultValue(0); + } + } +} diff --git a/src/NzbDrone.Core/Datastore/TableMapping.cs b/src/NzbDrone.Core/Datastore/TableMapping.cs index 74e6c6b28..7942732d6 100644 --- a/src/NzbDrone.Core/Datastore/TableMapping.cs +++ b/src/NzbDrone.Core/Datastore/TableMapping.cs @@ -63,7 +63,8 @@ namespace NzbDrone.Core.Datastore Mapper.Entity("Notifications").RegisterModel() .Ignore(x => x.ImplementationName) - .Ignore(i => i.SupportsOnHealthIssue); + .Ignore(i => i.SupportsOnHealthIssue) + .Ignore(i => i.SupportsOnApplicationUpdate); Mapper.Entity("IndexerProxies").RegisterModel() .Ignore(x => x.ImplementationName); diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index 16f81c7b7..f8b175d7d 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -262,6 +262,9 @@ "NoUpdatesAreAvailable": "No updates are available", "OAuthPopupMessage": "Pop-ups are being blocked by your browser", "Ok": "Ok", + "OnApplicationUpdate": "On Application Update", + "OnApplicationUpdateHelpText": "On Application Update", + "OnHealthIssue": "On Health Issue", "OnHealthIssueHelpText": "On Health Issue", "OpenBrowserOnStart": "Open browser on start", "OpenThisModal": "Open This Modal", diff --git a/src/NzbDrone.Core/Notifications/ApplicationUpdateMessage.cs b/src/NzbDrone.Core/Notifications/ApplicationUpdateMessage.cs new file mode 100644 index 000000000..1819ad423 --- /dev/null +++ b/src/NzbDrone.Core/Notifications/ApplicationUpdateMessage.cs @@ -0,0 +1,16 @@ +using System; + +namespace NzbDrone.Core.Notifications +{ + public class ApplicationUpdateMessage + { + public string Message { get; set; } + public Version PreviousVersion { get; set; } + public Version NewVersion { get; set; } + + public override string ToString() + { + return NewVersion.ToString(); + } + } +} diff --git a/src/NzbDrone.Core/Notifications/Boxcar/Boxcar.cs b/src/NzbDrone.Core/Notifications/Boxcar/Boxcar.cs index dedf30421..db6908019 100644 --- a/src/NzbDrone.Core/Notifications/Boxcar/Boxcar.cs +++ b/src/NzbDrone.Core/Notifications/Boxcar/Boxcar.cs @@ -20,6 +20,11 @@ namespace NzbDrone.Core.Notifications.Boxcar _proxy.SendNotification(HEALTH_ISSUE_TITLE, message.Message, Settings); } + public override void OnApplicationUpdate(ApplicationUpdateMessage message) + { + _proxy.SendNotification(APPLICATION_UPDATE_TITLE, message.Message, Settings); + } + public override ValidationResult Test() { var failures = new List(); diff --git a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs index 83130cd53..f7d728ca3 100755 --- a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs +++ b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs @@ -44,6 +44,18 @@ namespace NzbDrone.Core.Notifications.CustomScript ExecuteScript(environmentVariables); } + public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage) + { + var environmentVariables = new StringDictionary(); + + environmentVariables.Add("Prowlarr_EventType", "ApplicationUpdate"); + environmentVariables.Add("Prowlarr_Update_Message", updateMessage.Message); + environmentVariables.Add("Prowlarr_Update_NewVersion", updateMessage.NewVersion.ToString()); + environmentVariables.Add("Prowlarr_Update_PreviousVersion", updateMessage.PreviousVersion.ToString()); + + ExecuteScript(environmentVariables); + } + public override ValidationResult Test() { var failures = new List(); diff --git a/src/NzbDrone.Core/Notifications/Discord/Discord.cs b/src/NzbDrone.Core/Notifications/Discord/Discord.cs index 414d784fe..2985af45a 100644 --- a/src/NzbDrone.Core/Notifications/Discord/Discord.cs +++ b/src/NzbDrone.Core/Notifications/Discord/Discord.cs @@ -42,6 +42,41 @@ namespace NzbDrone.Core.Notifications.Discord _proxy.SendPayload(payload, Settings); } + public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage) + { + var attachments = new List + { + new Embed + { + Author = new DiscordAuthor + { + Name = Settings.Author.IsNullOrWhiteSpace() ? Environment.MachineName : Settings.Author, + IconUrl = "https://raw.githubusercontent.com/Prowlarr/Prowlarr/develop/Logo/256.png" + }, + Title = APPLICATION_UPDATE_TITLE, + Timestamp = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), + Color = (int)DiscordColors.Standard, + Fields = new List() + { + new DiscordField() + { + Name = "Previous Version", + Value = updateMessage.PreviousVersion.ToString() + }, + new DiscordField() + { + Name = "New Version", + Value = updateMessage.NewVersion.ToString() + } + }, + } + }; + + var payload = CreatePayload(null, attachments); + + _proxy.SendPayload(payload, Settings); + } + public override ValidationResult Test() { var failures = new List(); diff --git a/src/NzbDrone.Core/Notifications/Email/Email.cs b/src/NzbDrone.Core/Notifications/Email/Email.cs index 56b58b7ad..f40c20da6 100644 --- a/src/NzbDrone.Core/Notifications/Email/Email.cs +++ b/src/NzbDrone.Core/Notifications/Email/Email.cs @@ -28,6 +28,13 @@ namespace NzbDrone.Core.Notifications.Email SendEmail(Settings, HEALTH_ISSUE_TITLE_BRANDED, message.Message); } + public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage) + { + var body = $"{updateMessage.Message}"; + + SendEmail(Settings, APPLICATION_UPDATE_TITLE_BRANDED, body); + } + public override ValidationResult Test() { var failures = new List(); diff --git a/src/NzbDrone.Core/Notifications/Gotify/Gotify.cs b/src/NzbDrone.Core/Notifications/Gotify/Gotify.cs index f58b947ac..a8c631a95 100644 --- a/src/NzbDrone.Core/Notifications/Gotify/Gotify.cs +++ b/src/NzbDrone.Core/Notifications/Gotify/Gotify.cs @@ -24,6 +24,11 @@ namespace NzbDrone.Core.Notifications.Gotify _proxy.SendNotification(HEALTH_ISSUE_TITLE, healthCheck.Message, Settings); } + public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage) + { + _proxy.SendNotification(APPLICATION_UPDATE_TITLE, updateMessage.Message, Settings); + } + public override ValidationResult Test() { var failures = new List(); diff --git a/src/NzbDrone.Core/Notifications/INotification.cs b/src/NzbDrone.Core/Notifications/INotification.cs index e2ef5dfca..de71139d6 100644 --- a/src/NzbDrone.Core/Notifications/INotification.cs +++ b/src/NzbDrone.Core/Notifications/INotification.cs @@ -7,7 +7,9 @@ namespace NzbDrone.Core.Notifications string Link { get; } void OnHealthIssue(HealthCheck.HealthCheck healthCheck); + void OnApplicationUpdate(ApplicationUpdateMessage updateMessage); void ProcessQueue(); bool SupportsOnHealthIssue { get; } + bool SupportsOnApplicationUpdate { get; } } } diff --git a/src/NzbDrone.Core/Notifications/Join/Join.cs b/src/NzbDrone.Core/Notifications/Join/Join.cs index e5da40e0e..cb9243429 100644 --- a/src/NzbDrone.Core/Notifications/Join/Join.cs +++ b/src/NzbDrone.Core/Notifications/Join/Join.cs @@ -22,6 +22,11 @@ namespace NzbDrone.Core.Notifications.Join _proxy.SendNotification(HEALTH_ISSUE_TITLE_BRANDED, message.Message, Settings); } + public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage) + { + _proxy.SendNotification(APPLICATION_UPDATE_TITLE_BRANDED, updateMessage.Message, Settings); + } + public override ValidationResult Test() { var failures = new List(); diff --git a/src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs b/src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs index 5956e17f1..255567784 100644 --- a/src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs +++ b/src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs @@ -29,6 +29,18 @@ namespace NzbDrone.Core.Notifications.Notifiarr _proxy.SendNotification(variables, Settings); } + public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage) + { + var variables = new StringDictionary(); + + variables.Add("Prowlarr_EventType", "ApplicationUpdate"); + variables.Add("Prowlarr_Update_Message", updateMessage.Message); + variables.Add("Prowlarr_Update_NewVersion", updateMessage.NewVersion.ToString()); + variables.Add("Prowlarr_Update_PreviousVersion", updateMessage.PreviousVersion.ToString()); + + _proxy.SendNotification(variables, Settings); + } + public override ValidationResult Test() { var failures = new List(); diff --git a/src/NzbDrone.Core/Notifications/NotificationBase.cs b/src/NzbDrone.Core/Notifications/NotificationBase.cs index 9de1f34f3..67eee85ef 100644 --- a/src/NzbDrone.Core/Notifications/NotificationBase.cs +++ b/src/NzbDrone.Core/Notifications/NotificationBase.cs @@ -9,8 +9,10 @@ namespace NzbDrone.Core.Notifications where TSettings : IProviderConfig, new() { protected const string HEALTH_ISSUE_TITLE = "Health Check Failure"; + protected const string APPLICATION_UPDATE_TITLE = "Application Updated"; protected const string HEALTH_ISSUE_TITLE_BRANDED = "Prowlarr - " + HEALTH_ISSUE_TITLE; + protected const string APPLICATION_UPDATE_TITLE_BRANDED = "Prowlarr - " + APPLICATION_UPDATE_TITLE; public abstract string Name { get; } @@ -29,11 +31,16 @@ namespace NzbDrone.Core.Notifications { } + public virtual void OnApplicationUpdate(ApplicationUpdateMessage updateMessage) + { + } + public virtual void ProcessQueue() { } public bool SupportsOnHealthIssue => HasConcreteImplementation("OnHealthIssue"); + public bool SupportsOnApplicationUpdate => HasConcreteImplementation("OnApplicationUpdate"); protected TSettings Settings => (TSettings)Definition.Settings; diff --git a/src/NzbDrone.Core/Notifications/NotificationDefinition.cs b/src/NzbDrone.Core/Notifications/NotificationDefinition.cs index 7bc58d689..0d94f377f 100644 --- a/src/NzbDrone.Core/Notifications/NotificationDefinition.cs +++ b/src/NzbDrone.Core/Notifications/NotificationDefinition.cs @@ -5,9 +5,11 @@ namespace NzbDrone.Core.Notifications public class NotificationDefinition : ProviderDefinition { public bool OnHealthIssue { get; set; } + public bool OnApplicationUpdate { get; set; } public bool SupportsOnHealthIssue { get; set; } public bool IncludeHealthWarnings { get; set; } + public bool SupportsOnApplicationUpdate { get; set; } - public override bool Enable => OnHealthIssue; + public override bool Enable => OnHealthIssue || OnApplicationUpdate; } } diff --git a/src/NzbDrone.Core/Notifications/NotificationFactory.cs b/src/NzbDrone.Core/Notifications/NotificationFactory.cs index 05da34cf5..1c111d4c8 100644 --- a/src/NzbDrone.Core/Notifications/NotificationFactory.cs +++ b/src/NzbDrone.Core/Notifications/NotificationFactory.cs @@ -10,6 +10,7 @@ namespace NzbDrone.Core.Notifications public interface INotificationFactory : IProviderFactory { List OnHealthIssueEnabled(); + List OnApplicationUpdateEnabled(); } public class NotificationFactory : ProviderFactory, INotificationFactory @@ -24,11 +25,17 @@ namespace NzbDrone.Core.Notifications return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnHealthIssue).ToList(); } + public List OnApplicationUpdateEnabled() + { + return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnApplicationUpdate).ToList(); + } + public override void SetProviderCharacteristics(INotification provider, NotificationDefinition definition) { base.SetProviderCharacteristics(provider, definition); definition.SupportsOnHealthIssue = provider.SupportsOnHealthIssue; + definition.SupportsOnApplicationUpdate = provider.SupportsOnApplicationUpdate; } } } diff --git a/src/NzbDrone.Core/Notifications/NotificationService.cs b/src/NzbDrone.Core/Notifications/NotificationService.cs index 9f820a035..aa17b2a28 100644 --- a/src/NzbDrone.Core/Notifications/NotificationService.cs +++ b/src/NzbDrone.Core/Notifications/NotificationService.cs @@ -2,12 +2,14 @@ using System; using NLog; using NzbDrone.Core.HealthCheck; using NzbDrone.Core.Messaging.Events; +using NzbDrone.Core.Update.History.Events; namespace NzbDrone.Core.Notifications { public class NotificationService : IHandle, - IHandleAsync + IHandleAsync, + IHandle { private readonly INotificationFactory _notificationFactory; private readonly Logger _logger; @@ -56,6 +58,26 @@ namespace NzbDrone.Core.Notifications ProcessQueue(); } + public void Handle(UpdateInstalledEvent message) + { + var updateMessage = new ApplicationUpdateMessage(); + updateMessage.Message = $"Prowlarr updated from {message.PreviousVerison.ToString()} to {message.NewVersion.ToString()}"; + updateMessage.PreviousVersion = message.PreviousVerison; + updateMessage.NewVersion = message.NewVersion; + + foreach (var notification in _notificationFactory.OnApplicationUpdateEnabled()) + { + try + { + notification.OnApplicationUpdate(updateMessage); + } + catch (Exception ex) + { + _logger.Warn(ex, "Unable to send OnApplicationUpdate notification to: " + notification.Definition.Name); + } + } + } + private void ProcessQueue() { foreach (var notification in _notificationFactory.GetAvailableProviders()) diff --git a/src/NzbDrone.Core/Notifications/Prowl/Prowl.cs b/src/NzbDrone.Core/Notifications/Prowl/Prowl.cs index c30209f19..3e1ace185 100644 --- a/src/NzbDrone.Core/Notifications/Prowl/Prowl.cs +++ b/src/NzbDrone.Core/Notifications/Prowl/Prowl.cs @@ -21,6 +21,11 @@ namespace NzbDrone.Core.Notifications.Prowl _prowlProxy.SendNotification(HEALTH_ISSUE_TITLE, healthCheck.Message, Settings); } + public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage) + { + _prowlProxy.SendNotification(APPLICATION_UPDATE_TITLE, updateMessage.Message, Settings); + } + public override ValidationResult Test() { var failures = new List(); diff --git a/src/NzbDrone.Core/Notifications/PushBullet/PushBullet.cs b/src/NzbDrone.Core/Notifications/PushBullet/PushBullet.cs index 209b536eb..6b2c4616c 100644 --- a/src/NzbDrone.Core/Notifications/PushBullet/PushBullet.cs +++ b/src/NzbDrone.Core/Notifications/PushBullet/PushBullet.cs @@ -24,6 +24,11 @@ namespace NzbDrone.Core.Notifications.PushBullet _proxy.SendNotification(HEALTH_ISSUE_TITLE_BRANDED, healthCheck.Message, Settings); } + public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage) + { + _proxy.SendNotification(APPLICATION_UPDATE_TITLE_BRANDED, updateMessage.Message, Settings); + } + public override ValidationResult Test() { var failures = new List(); diff --git a/src/NzbDrone.Core/Notifications/Pushover/Pushover.cs b/src/NzbDrone.Core/Notifications/Pushover/Pushover.cs index c31bd4ceb..0d8aa43d1 100644 --- a/src/NzbDrone.Core/Notifications/Pushover/Pushover.cs +++ b/src/NzbDrone.Core/Notifications/Pushover/Pushover.cs @@ -21,6 +21,11 @@ namespace NzbDrone.Core.Notifications.Pushover _proxy.SendNotification(HEALTH_ISSUE_TITLE, healthCheck.Message, Settings); } + public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage) + { + _proxy.SendNotification(APPLICATION_UPDATE_TITLE, updateMessage.Message, Settings); + } + public override ValidationResult Test() { var failures = new List(); diff --git a/src/NzbDrone.Core/Notifications/SendGrid/SendGrid.cs b/src/NzbDrone.Core/Notifications/SendGrid/SendGrid.cs index d834cfab4..9d25e57d6 100644 --- a/src/NzbDrone.Core/Notifications/SendGrid/SendGrid.cs +++ b/src/NzbDrone.Core/Notifications/SendGrid/SendGrid.cs @@ -24,6 +24,11 @@ namespace NzbDrone.Core.Notifications.SendGrid _proxy.SendNotification(HEALTH_ISSUE_TITLE, healthCheck.Message, Settings); } + public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage) + { + _proxy.SendNotification(APPLICATION_UPDATE_TITLE, updateMessage.Message, Settings); + } + public override ValidationResult Test() { var failures = new List(); diff --git a/src/NzbDrone.Core/Notifications/Slack/Slack.cs b/src/NzbDrone.Core/Notifications/Slack/Slack.cs index e9c9a23ed..6737443f5 100644 --- a/src/NzbDrone.Core/Notifications/Slack/Slack.cs +++ b/src/NzbDrone.Core/Notifications/Slack/Slack.cs @@ -36,6 +36,23 @@ namespace NzbDrone.Core.Notifications.Slack _proxy.SendPayload(payload, Settings); } + public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage) + { + var attachments = new List + { + new Attachment + { + Title = Environment.MachineName, + Text = updateMessage.Message, + Color = "good" + } + }; + + var payload = CreatePayload("Application Updated", attachments); + + _proxy.SendPayload(payload, Settings); + } + public override ValidationResult Test() { var failures = new List(); diff --git a/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs b/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs index 93a919fea..d052ce73d 100644 --- a/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs +++ b/src/NzbDrone.Core/Notifications/Telegram/Telegram.cs @@ -21,6 +21,11 @@ namespace NzbDrone.Core.Notifications.Telegram _proxy.SendNotification(HEALTH_ISSUE_TITLE, healthCheck.Message, Settings); } + public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage) + { + _proxy.SendNotification(APPLICATION_UPDATE_TITLE, updateMessage.Message, Settings); + } + public override ValidationResult Test() { var failures = new List(); diff --git a/src/NzbDrone.Core/Notifications/Twitter/Twitter.cs b/src/NzbDrone.Core/Notifications/Twitter/Twitter.cs index 9d788e733..b33bfada9 100644 --- a/src/NzbDrone.Core/Notifications/Twitter/Twitter.cs +++ b/src/NzbDrone.Core/Notifications/Twitter/Twitter.cs @@ -23,6 +23,11 @@ namespace NzbDrone.Core.Notifications.Twitter _twitterService.SendNotification($"Health Issue: {healthCheck.Message}", Settings); } + public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage) + { + _twitterService.SendNotification($"Application Updated: {updateMessage.Message}", Settings); + } + public override object RequestAction(string action, IDictionary query) { if (action == "startOAuth") diff --git a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs index 0c36baf59..16c5e9983 100755 --- a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs @@ -19,13 +19,26 @@ namespace NzbDrone.Core.Notifications.Webhook public override void OnHealthIssue(HealthCheck.HealthCheck healthCheck) { var payload = new WebhookHealthPayload - { - EventType = WebhookEventType.Health, - Level = healthCheck.Type, - Message = healthCheck.Message, - Type = healthCheck.Source.Name, - WikiUrl = healthCheck.WikiUrl?.ToString() - }; + { + EventType = WebhookEventType.Health, + Level = healthCheck.Type, + Message = healthCheck.Message, + Type = healthCheck.Source.Name, + WikiUrl = healthCheck.WikiUrl?.ToString() + }; + + _proxy.SendWebhook(payload, Settings); + } + + public override void OnApplicationUpdate(ApplicationUpdateMessage updateMessage) + { + var payload = new WebhookApplicationUpdatePayload + { + EventType = WebhookEventType.ApplicationUpdate, + Message = updateMessage.Message, + PreviousVersion = updateMessage.PreviousVersion.ToString(), + NewVersion = updateMessage.NewVersion.ToString() + }; _proxy.SendWebhook(payload, Settings); } diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookApplicationUpdatePayload.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookApplicationUpdatePayload.cs new file mode 100644 index 000000000..e05be69bc --- /dev/null +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookApplicationUpdatePayload.cs @@ -0,0 +1,11 @@ +using NzbDrone.Core.HealthCheck; + +namespace NzbDrone.Core.Notifications.Webhook +{ + public class WebhookApplicationUpdatePayload : WebhookPayload + { + public string Message { get; set; } + public string PreviousVersion { get; set; } + public string NewVersion { get; set; } + } +} diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookEventType.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookEventType.cs index 8c7036d92..fdc765877 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookEventType.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookEventType.cs @@ -12,6 +12,7 @@ namespace NzbDrone.Core.Notifications.Webhook Grab, Download, Rename, - Health + Health, + ApplicationUpdate } } diff --git a/src/Prowlarr.Api.V1/Notifications/NotificationResource.cs b/src/Prowlarr.Api.V1/Notifications/NotificationResource.cs index 290610e3a..d1b751df1 100644 --- a/src/Prowlarr.Api.V1/Notifications/NotificationResource.cs +++ b/src/Prowlarr.Api.V1/Notifications/NotificationResource.cs @@ -6,8 +6,10 @@ namespace Prowlarr.Api.V1.Notifications { public string Link { get; set; } public bool OnHealthIssue { get; set; } + public bool OnApplicationUpdate { get; set; } public bool SupportsOnHealthIssue { get; set; } public bool IncludeHealthWarnings { get; set; } + public bool SupportsOnApplicationUpdate { get; set; } public string TestCommand { get; set; } } @@ -25,6 +27,8 @@ namespace Prowlarr.Api.V1.Notifications resource.OnHealthIssue = definition.OnHealthIssue; resource.SupportsOnHealthIssue = definition.SupportsOnHealthIssue; resource.IncludeHealthWarnings = definition.IncludeHealthWarnings; + resource.OnApplicationUpdate = definition.OnApplicationUpdate; + resource.SupportsOnApplicationUpdate = definition.SupportsOnApplicationUpdate; return resource; } @@ -41,6 +45,8 @@ namespace Prowlarr.Api.V1.Notifications definition.OnHealthIssue = resource.OnHealthIssue; definition.SupportsOnHealthIssue = resource.SupportsOnHealthIssue; definition.IncludeHealthWarnings = resource.IncludeHealthWarnings; + definition.OnApplicationUpdate = resource.OnApplicationUpdate; + definition.SupportsOnApplicationUpdate = resource.SupportsOnApplicationUpdate; return definition; }