Migrate ActivityLogEntryPoint.OnPluginUninstalled to IEventConsumer
This commit is contained in:
parent
b7f21971f4
commit
0da7c0568d
|
@ -2,7 +2,6 @@ using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Jellyfin.Data.Entities;
|
using Jellyfin.Data.Entities;
|
||||||
using MediaBrowser.Common.Plugins;
|
|
||||||
using MediaBrowser.Common.Updates;
|
using MediaBrowser.Common.Updates;
|
||||||
using MediaBrowser.Controller.Plugins;
|
using MediaBrowser.Controller.Plugins;
|
||||||
using MediaBrowser.Controller.Session;
|
using MediaBrowser.Controller.Session;
|
||||||
|
@ -45,7 +44,6 @@ namespace Emby.Server.Implementations.Activity
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public Task RunAsync()
|
public Task RunAsync()
|
||||||
{
|
{
|
||||||
_installationManager.PluginUninstalled += OnPluginUninstalled;
|
|
||||||
_installationManager.PluginUpdated += OnPluginUpdated;
|
_installationManager.PluginUpdated += OnPluginUpdated;
|
||||||
_installationManager.PackageInstallationFailed += OnPackageInstallationFailed;
|
_installationManager.PackageInstallationFailed += OnPackageInstallationFailed;
|
||||||
|
|
||||||
|
@ -123,18 +121,6 @@ namespace Emby.Server.Implementations.Activity
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void OnPluginUninstalled(object sender, IPlugin e)
|
|
||||||
{
|
|
||||||
await CreateLogEntry(new ActivityLog(
|
|
||||||
string.Format(
|
|
||||||
CultureInfo.InvariantCulture,
|
|
||||||
_localization.GetLocalizedString("PluginUninstalledWithName"),
|
|
||||||
e.Name),
|
|
||||||
NotificationType.PluginUninstalled.ToString(),
|
|
||||||
Guid.Empty))
|
|
||||||
.ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void OnPackageInstallationFailed(object sender, InstallationFailedEventArgs e)
|
private async void OnPackageInstallationFailed(object sender, InstallationFailedEventArgs e)
|
||||||
{
|
{
|
||||||
var installationInfo = e.InstallationInfo;
|
var installationInfo = e.InstallationInfo;
|
||||||
|
@ -161,7 +147,6 @@ namespace Emby.Server.Implementations.Activity
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_installationManager.PluginUninstalled -= OnPluginUninstalled;
|
|
||||||
_installationManager.PluginUpdated -= OnPluginUpdated;
|
_installationManager.PluginUpdated -= OnPluginUpdated;
|
||||||
_installationManager.PackageInstallationFailed -= OnPackageInstallationFailed;
|
_installationManager.PackageInstallationFailed -= OnPackageInstallationFailed;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
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 uninstalled.
|
||||||
|
/// </summary>
|
||||||
|
public class PluginUninstalledLogger : IEventConsumer<PluginUninstalledEventArgs>
|
||||||
|
{
|
||||||
|
private readonly ILocalizationManager _localizationManager;
|
||||||
|
private readonly IActivityManager _activityManager;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="PluginUninstalledLogger"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="localizationManager">The localization manager.</param>
|
||||||
|
/// <param name="activityManager">The activity manager.</param>
|
||||||
|
public PluginUninstalledLogger(ILocalizationManager localizationManager, IActivityManager activityManager)
|
||||||
|
{
|
||||||
|
_localizationManager = localizationManager;
|
||||||
|
_activityManager = activityManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task OnEvent(PluginUninstalledEventArgs e)
|
||||||
|
{
|
||||||
|
await _activityManager.CreateAsync(new ActivityLog(
|
||||||
|
string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
_localizationManager.GetLocalizedString("PluginUninstalledWithName"),
|
||||||
|
e.Argument.Name),
|
||||||
|
NotificationType.PluginUninstalled.ToString(),
|
||||||
|
Guid.Empty))
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
using Jellyfin.Data.Events;
|
||||||
|
using MediaBrowser.Common.Plugins;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Controller.Events.Updates
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// An event that occurs when a plugin is uninstalled.
|
||||||
|
/// </summary>
|
||||||
|
public class PluginUninstalledEventArgs : GenericEventArgs<IPlugin>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="PluginUninstalledEventArgs"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="arg">The plugin.</param>
|
||||||
|
public PluginUninstalledEventArgs(IPlugin arg) : base(arg)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user