The Free Software Media System - Server Backend & API
Migrate ActivityLogEntryPoint.OnPluginInstalled to IEventConsumer
Patrick Barronb7f21971f43d
diff --git a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.csindex 40fc7d8907..600c1d3ea2 100644--- a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs+++ b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs@@ -45,7 +45,6 @@ namespace Emby.Server.Implementations.Activity/// <inheritdoc />public Task RunAsync(){- _installationManager.PluginInstalled += OnPluginInstalled;_installationManager.PluginUninstalled += OnPluginUninstalled;_installationManager.PluginUpdated += OnPluginUpdated;_installationManager.PackageInstallationFailed += OnPackageInstallationFailed;@@ -136,23 +135,6 @@ namespace Emby.Server.Implementations.Activity.ConfigureAwait(false);}- private async void OnPluginInstalled(object sender, InstallationInfo e)- {- await CreateLogEntry(new ActivityLog(- string.Format(- CultureInfo.InvariantCulture,- _localization.GetLocalizedString("PluginInstalledWithName"),- e.Name),- NotificationType.PluginInstalled.ToString(),- Guid.Empty)- {- ShortOverview = string.Format(- CultureInfo.InvariantCulture,- _localization.GetLocalizedString("VersionNumber"),- e.Version)- }).ConfigureAwait(false);- }-private async void OnPackageInstallationFailed(object sender, InstallationFailedEventArgs e){var installationInfo = e.InstallationInfo;@@ -179,7 +161,6 @@ namespace Emby.Server.Implementations.Activity/// <inheritdoc />public void Dispose(){- _installationManager.PluginInstalled -= OnPluginInstalled;_installationManager.PluginUninstalled -= OnPluginUninstalled;_installationManager.PluginUpdated -= OnPluginUpdated;_installationManager.PackageInstallationFailed -= OnPackageInstallationFailed;diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginInstalledLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginInstalledLogger.csnew file mode 100644index 0000000000..8837172dbe--- /dev/null+++ b/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginInstalledLogger.cs@@ -0,0 +1,50 @@+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 installed.+ /// </summary>+ public class PluginInstalledLogger : IEventConsumer<PluginInstalledEventArgs>+ {+ private readonly ILocalizationManager _localizationManager;+ private readonly IActivityManager _activityManager;++ /// <summary>+ /// Initializes a new instance of the <see cref="PluginInstalledLogger"/> class.+ /// </summary>+ /// <param name="localizationManager">The localization manager.</param>+ /// <param name="activityManager">The activity manager.</param>+ public PluginInstalledLogger(ILocalizationManager localizationManager, IActivityManager activityManager)+ {+ _localizationManager = localizationManager;+ _activityManager = activityManager;+ }++ /// <inheritdoc />+ public async Task OnEvent(PluginInstalledEventArgs eventArgs)+ {+ await _activityManager.CreateAsync(new ActivityLog(+ string.Format(+ CultureInfo.InvariantCulture,+ _localizationManager.GetLocalizedString("PluginInstalledWithName"),+ eventArgs.Argument.Name),+ NotificationType.PluginInstalled.ToString(),+ Guid.Empty)+ {+ ShortOverview = string.Format(+ CultureInfo.InvariantCulture,+ _localizationManager.GetLocalizedString("VersionNumber"),+ eventArgs.Argument.Version)+ }).ConfigureAwait(false);+ }+ }+}diff --git a/MediaBrowser.Controller/Events/Updates/PluginInstalledEventArgs.cs b/MediaBrowser.Controller/Events/Updates/PluginInstalledEventArgs.csnew file mode 100644index 0000000000..dfadc9f61f--- /dev/null+++ b/MediaBrowser.Controller/Events/Updates/PluginInstalledEventArgs.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 installed.+ /// </summary>+ public class PluginInstalledEventArgs : GenericEventArgs<InstallationInfo>+ {+ /// <summary>+ /// Initializes a new instance of the <see cref="PluginInstalledEventArgs"/> class.+ /// </summary>+ /// <param name="arg">The installation info.</param>+ public PluginInstalledEventArgs(InstallationInfo arg) : base(arg)+ {+ }+ }+}