mirror of https://github.com/Radarr/Radarr
New: Add Changes to UpdatedEvent Notifications
This commit is contained in:
parent
fcebfe6759
commit
1b4a6b1309
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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())
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<string> NewChanges { get; set; }
|
||||
public List<string> FixedChanges { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ApplicationStartedEvent>, IHandleAsync<ApplicationStartedEvent>
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue