The Free Software Media System - Server Backend & API
Migrate ServerEventNotifier.OnPackageInstalling to IEventConsumer
Patrick Barronb7ceb40d6efe
diff --git a/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs b/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.csindex 3d58b91e1d..068872420b 100644--- a/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs+++ b/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs@@ -38,7 +38,6 @@ namespace Emby.Server.Implementations.EntryPointspublic Task RunAsync(){_installationManager.PluginUninstalled += OnPluginUninstalled;- _installationManager.PackageInstalling += OnPackageInstalling;_installationManager.PackageInstallationCancelled += OnPackageInstallationCancelled;_installationManager.PackageInstallationCompleted += OnPackageInstallationCompleted;_installationManager.PackageInstallationFailed += OnPackageInstallationFailed;@@ -46,11 +45,6 @@ namespace Emby.Server.Implementations.EntryPointsreturn Task.CompletedTask;}- private async void OnPackageInstalling(object sender, InstallationInfo e)- {- await SendMessageToAdminSessions("PackageInstalling", e).ConfigureAwait(false);- }-private async void OnPackageInstallationCancelled(object sender, InstallationInfo e){await SendMessageToAdminSessions("PackageInstallationCancelled", e).ConfigureAwait(false);@@ -103,7 +97,6 @@ namespace Emby.Server.Implementations.EntryPointsif (dispose){_installationManager.PluginUninstalled -= OnPluginUninstalled;- _installationManager.PackageInstalling -= OnPackageInstalling;_installationManager.PackageInstallationCancelled -= OnPackageInstallationCancelled;_installationManager.PackageInstallationCompleted -= OnPackageInstallationCompleted;_installationManager.PackageInstallationFailed -= OnPackageInstallationFailed;diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginInstallingNotifier.cs b/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginInstallingNotifier.csnew file mode 100644index 0000000000..f691d11a7d--- /dev/null+++ b/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginInstallingNotifier.cs@@ -0,0 +1,31 @@+using System.Threading;+using System.Threading.Tasks;+using MediaBrowser.Controller.Events;+using MediaBrowser.Controller.Events.Updates;+using MediaBrowser.Controller.Session;++namespace Jellyfin.Server.Implementations.Events.Consumers.Updates+{+ /// <summary>+ /// Notifies admin users when a plugin is being installed.+ /// </summary>+ public class PluginInstallingNotifier : IEventConsumer<PluginInstallingEventArgs>+ {+ private readonly ISessionManager _sessionManager;++ /// <summary>+ /// Initializes a new instance of the <see cref="PluginInstallingNotifier"/> class.+ /// </summary>+ /// <param name="sessionManager">The session manager.</param>+ public PluginInstallingNotifier(ISessionManager sessionManager)+ {+ _sessionManager = sessionManager;+ }++ /// <inheritdoc />+ public async Task OnEvent(PluginInstallingEventArgs eventArgs)+ {+ await _sessionManager.SendMessageToAdminSessions("PackageInstalling", eventArgs.Argument, CancellationToken.None).ConfigureAwait(false);+ }+ }+}diff --git a/MediaBrowser.Controller/Events/Updates/PluginInstallingEventArgs.cs b/MediaBrowser.Controller/Events/Updates/PluginInstallingEventArgs.csnew file mode 100644index 0000000000..045a600272--- /dev/null+++ b/MediaBrowser.Controller/Events/Updates/PluginInstallingEventArgs.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 installing.+ /// </summary>+ public class PluginInstallingEventArgs : GenericEventArgs<InstallationInfo>+ {+ /// <summary>+ /// Initializes a new instance of the <see cref="PluginInstallingEventArgs"/> class.+ /// </summary>+ /// <param name="arg">The installation info.</param>+ public PluginInstallingEventArgs(InstallationInfo arg) : base(arg)+ {+ }+ }+}