The Free Software Media System - Server Backend & API
Migrate ActivityLogEntryPoint.OnPluginUpdated to IEventConsumer
Patrick Barrone9244448809c
diff --git a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.csindex ba0bf9ea2e..ee058fd468 100644--- a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs+++ b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs@@ -8,7 +8,6 @@ using MediaBrowser.Controller.Session;using MediaBrowser.Model.Activity;using MediaBrowser.Model.Globalization;using MediaBrowser.Model.Notifications;-using MediaBrowser.Model.Updates;namespace Emby.Server.Implementations.Activity{@@ -44,7 +43,6 @@ namespace Emby.Server.Implementations.Activity/// <inheritdoc />public Task RunAsync(){- _installationManager.PluginUpdated += OnPluginUpdated;_installationManager.PackageInstallationFailed += OnPackageInstallationFailed;_sessionManager.SessionStarted += OnSessionStarted;@@ -103,24 +101,6 @@ namespace Emby.Server.Implementations.Activity}).ConfigureAwait(false);}- private async void OnPluginUpdated(object sender, InstallationInfo e)- {- await CreateLogEntry(new ActivityLog(- string.Format(- CultureInfo.InvariantCulture,- _localization.GetLocalizedString("PluginUpdatedWithName"),- e.Name),- NotificationType.PluginUpdateInstalled.ToString(),- Guid.Empty)- {- ShortOverview = string.Format(- CultureInfo.InvariantCulture,- _localization.GetLocalizedString("VersionNumber"),- e.Version),- Overview = e.Changelog- }).ConfigureAwait(false);- }-private async void OnPackageInstallationFailed(object sender, InstallationFailedEventArgs e){var installationInfo = e.InstallationInfo;@@ -147,7 +127,6 @@ namespace Emby.Server.Implementations.Activity/// <inheritdoc />public void Dispose(){- _installationManager.PluginUpdated -= OnPluginUpdated;_installationManager.PackageInstallationFailed -= OnPackageInstallationFailed;_sessionManager.SessionStarted -= OnSessionStarted;diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginUpdatedLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginUpdatedLogger.csnew file mode 100644index 0000000000..9ce16f774f--- /dev/null+++ b/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginUpdatedLogger.cs@@ -0,0 +1,51 @@+using System;+using System.Globalization;+using System.Threading.Tasks;+using Jellyfin.Data.Entities;+using MediaBrowser.Controller.Events;+using MediaBrowser.Controller.Events.Updates;+using MediaBrowser.Model.Activity;+using MediaBrowser.Model.Globalization;+using MediaBrowser.Model.Notifications;++namespace Jellyfin.Server.Implementations.Events.Consumers.Updates+{+ /// <summary>+ /// Creates an entry in the activity log when a plugin is updated.+ /// </summary>+ public class PluginUpdatedLogger : IEventConsumer<PluginUpdatedEventArgs>+ {+ private readonly ILocalizationManager _localizationManager;+ private readonly IActivityManager _activityManager;++ /// <summary>+ /// Initializes a new instance of the <see cref="PluginUpdatedLogger"/> class.+ /// </summary>+ /// <param name="localizationManager">The localization manager.</param>+ /// <param name="activityManager">The activity manager.</param>+ public PluginUpdatedLogger(ILocalizationManager localizationManager, IActivityManager activityManager)+ {+ _localizationManager = localizationManager;+ _activityManager = activityManager;+ }++ /// <inheritdoc />+ public async Task OnEvent(PluginUpdatedEventArgs eventArgs)+ {+ await _activityManager.CreateAsync(new ActivityLog(+ string.Format(+ CultureInfo.InvariantCulture,+ _localizationManager.GetLocalizedString("PluginUpdatedWithName"),+ eventArgs.Argument.Name),+ NotificationType.PluginUpdateInstalled.ToString(),+ Guid.Empty)+ {+ ShortOverview = string.Format(+ CultureInfo.InvariantCulture,+ _localizationManager.GetLocalizedString("VersionNumber"),+ eventArgs.Argument.Version),+ Overview = eventArgs.Argument.Changelog+ }).ConfigureAwait(false);+ }+ }+}diff --git a/MediaBrowser.Controller/Events/Updates/PluginUpdatedEventArgs.cs b/MediaBrowser.Controller/Events/Updates/PluginUpdatedEventArgs.csnew file mode 100644index 0000000000..661ca066a8--- /dev/null+++ b/MediaBrowser.Controller/Events/Updates/PluginUpdatedEventArgs.cs@@ -0,0 +1,19 @@+using Jellyfin.Data.Events;+using MediaBrowser.Model.Updates;++namespace MediaBrowser.Controller.Events.Updates+{+ /// <summary>+ /// An event that occurs when a plugin is updated.+ /// </summary>+ public class PluginUpdatedEventArgs : GenericEventArgs<InstallationInfo>+ {+ /// <summary>+ /// Initializes a new instance of the <see cref="PluginUpdatedEventArgs"/> class.+ /// </summary>+ /// <param name="arg">The installation info.</param>+ public PluginUpdatedEventArgs(InstallationInfo arg) : base(arg)+ {+ }+ }+}