diff --git a/src/NzbDrone.Core/Notifications/ApplicationUpdateMessage.cs b/src/NzbDrone.Core/Notifications/ApplicationUpdateMessage.cs index 1819ad423d..1673d57532 100644 --- a/src/NzbDrone.Core/Notifications/ApplicationUpdateMessage.cs +++ b/src/NzbDrone.Core/Notifications/ApplicationUpdateMessage.cs @@ -1,4 +1,5 @@ using System; +using NzbDrone.Core.Update; namespace NzbDrone.Core.Notifications { @@ -7,6 +8,7 @@ namespace NzbDrone.Core.Notifications public string Message { get; set; } public Version PreviousVersion { get; set; } public Version NewVersion { get; set; } + public UpdateChanges Changes { get; set; } public override string ToString() { diff --git a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs index b14eca6e84..27392454a7 100755 --- a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs +++ b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs @@ -212,6 +212,16 @@ namespace NzbDrone.Core.Notifications.CustomScript environmentVariables.Add("Radarr_Update_NewVersion", updateMessage.NewVersion.ToString()); environmentVariables.Add("Radarr_Update_PreviousVersion", updateMessage.PreviousVersion.ToString()); + if (updateMessage.Changes.New.Any()) + { + environmentVariables.Add("Radarr_Update_NewChanges", string.Join("|", updateMessage.Changes.New.Select(e => e))); + } + + if (updateMessage.Changes.Fixed.Any()) + { + environmentVariables.Add("Radarr_Update_FixedChanges", string.Join("|", updateMessage.Changes.Fixed.Select(e => e))); + } + ExecuteScript(environmentVariables); } diff --git a/src/NzbDrone.Core/Notifications/Discord/Discord.cs b/src/NzbDrone.Core/Notifications/Discord/Discord.cs index e7f8ef5a0b..d2e2f81146 100644 --- a/src/NzbDrone.Core/Notifications/Discord/Discord.cs +++ b/src/NzbDrone.Core/Notifications/Discord/Discord.cs @@ -317,6 +317,16 @@ namespace NzbDrone.Core.Notifications.Discord { Name = "New Version", Value = updateMessage.NewVersion.ToString() + }, + new DiscordField() + { + Name = "New", + Value = string.Format("```{0}```", string.Join(Environment.NewLine, updateMessage.Changes.New)) + }, + new DiscordField() + { + Name = "Fixed", + Value = string.Format("```{0}```", string.Join(Environment.NewLine, updateMessage.Changes.Fixed)) } }, } diff --git a/src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs b/src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs index 9f88f43f77..21252c8de2 100644 --- a/src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs +++ b/src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs @@ -176,6 +176,16 @@ namespace NzbDrone.Core.Notifications.Notifiarr variables.Add("Radarr_Update_NewVersion", updateMessage.NewVersion.ToString()); variables.Add("Radarr_Update_PreviousVersion", updateMessage.PreviousVersion.ToString()); + if (updateMessage.Changes.New.Any()) + { + variables.Add("Radarr_Update_NewChanges", string.Join("|", updateMessage.Changes.New.Select(e => e))); + } + + if (updateMessage.Changes.Fixed.Any()) + { + variables.Add("Radarr_Update_FixedChanges", string.Join("|", updateMessage.Changes.Fixed.Select(e => e))); + } + _proxy.SendNotification(variables, Settings); } diff --git a/src/NzbDrone.Core/Notifications/NotificationService.cs b/src/NzbDrone.Core/Notifications/NotificationService.cs index 2bfba51163..0a199afa71 100644 --- a/src/NzbDrone.Core/Notifications/NotificationService.cs +++ b/src/NzbDrone.Core/Notifications/NotificationService.cs @@ -198,6 +198,7 @@ namespace NzbDrone.Core.Notifications updateMessage.Message = $"Radarr updated from {message.PreviousVerison.ToString()} to {message.NewVersion.ToString()}"; updateMessage.PreviousVersion = message.PreviousVerison; updateMessage.NewVersion = message.NewVersion; + updateMessage.Changes = message.Changes; foreach (var notification in _notificationFactory.OnApplicationUpdateEnabled()) { diff --git a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs index f6f9837f4f..8609c4d144 100755 --- a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs @@ -136,7 +136,9 @@ namespace NzbDrone.Core.Notifications.Webhook EventType = WebhookEventType.ApplicationUpdate, Message = updateMessage.Message, PreviousVersion = updateMessage.PreviousVersion.ToString(), - NewVersion = updateMessage.NewVersion.ToString() + NewVersion = updateMessage.NewVersion.ToString(), + NewChanges = updateMessage.Changes.New, + FixedChanges = updateMessage.Changes.Fixed }; _proxy.SendWebhook(payload, Settings); diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookApplicationUpdatePayload.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookApplicationUpdatePayload.cs index 66a6ff3828..2a273de9b8 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookApplicationUpdatePayload.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookApplicationUpdatePayload.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; + namespace NzbDrone.Core.Notifications.Webhook { public class WebhookApplicationUpdatePayload : WebhookPayload @@ -5,5 +7,7 @@ namespace NzbDrone.Core.Notifications.Webhook public string Message { get; set; } public string PreviousVersion { get; set; } public string NewVersion { get; set; } + public List NewChanges { get; set; } + public List FixedChanges { get; set; } } } diff --git a/src/NzbDrone.Core/Update/Events/UpdateInstalledEvent.cs b/src/NzbDrone.Core/Update/Events/UpdateInstalledEvent.cs index 29290b17f9..c09258d130 100644 --- a/src/NzbDrone.Core/Update/Events/UpdateInstalledEvent.cs +++ b/src/NzbDrone.Core/Update/Events/UpdateInstalledEvent.cs @@ -7,11 +7,13 @@ namespace NzbDrone.Core.Update.History.Events { public Version PreviousVerison { get; set; } public Version NewVersion { get; set; } + public UpdateChanges Changes { get; set; } - public UpdateInstalledEvent(Version previousVersion, Version newVersion) + public UpdateInstalledEvent(Version previousVersion, Version newVersion, UpdateChanges changes) { PreviousVerison = previousVersion; NewVersion = newVersion; + Changes = changes; } } } diff --git a/src/NzbDrone.Core/Update/History/UpdateHistoryService.cs b/src/NzbDrone.Core/Update/History/UpdateHistoryService.cs index 09cf706022..970909a337 100644 --- a/src/NzbDrone.Core/Update/History/UpdateHistoryService.cs +++ b/src/NzbDrone.Core/Update/History/UpdateHistoryService.cs @@ -1,7 +1,9 @@ -using System; +using System; using System.Collections.Generic; +using System.Linq; using NLog; using NzbDrone.Common.EnvironmentInfo; +using NzbDrone.Core.Configuration; using NzbDrone.Core.Lifecycle; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Update.History.Events; @@ -17,13 +19,21 @@ namespace NzbDrone.Core.Update.History public class UpdateHistoryService : IUpdateHistoryService, IHandle, IHandleAsync { private readonly IUpdateHistoryRepository _repository; + private readonly IConfigFileProvider _configFileProvider; + private readonly IUpdatePackageProvider _updatePackageProvider; private readonly IEventAggregator _eventAggregator; private readonly Logger _logger; private Version _prevVersion; - public UpdateHistoryService(IUpdateHistoryRepository repository, IEventAggregator eventAggregator, Logger logger) + public UpdateHistoryService(IUpdateHistoryRepository repository, + IConfigFileProvider configFileProvider, + IUpdatePackageProvider updatePackageProvider, + IEventAggregator eventAggregator, + Logger logger) { _repository = repository; + _configFileProvider = configFileProvider; + _updatePackageProvider = updatePackageProvider; _eventAggregator = eventAggregator; _logger = logger; } @@ -93,7 +103,20 @@ namespace NzbDrone.Core.Update.History { if (_prevVersion != null) { - _eventAggregator.PublishEvent(new UpdateInstalledEvent(_prevVersion, BuildInfo.Version)); + var branch = _configFileProvider.Branch; + var version = BuildInfo.Version; + var packageChanges = _updatePackageProvider.GetRecentUpdates(branch, version, _prevVersion) + .Select(u => u.Changes); + + var changes = new UpdateChanges(); + + foreach (var change in packageChanges) + { + changes.New = change.New.Union(change.New).ToList(); + changes.Fixed = change.Fixed.Union(change.Fixed).ToList(); + } + + _eventAggregator.PublishEvent(new UpdateInstalledEvent(_prevVersion, BuildInfo.Version, changes)); } } }