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
{
///
/// Creates an entry in the activity log when a plugin is uninstalled.
///
public class PluginUninstalledLogger : IEventConsumer
{
private readonly ILocalizationManager _localizationManager;
private readonly IActivityManager _activityManager;
///
/// Initializes a new instance of the class.
///
/// The localization manager.
/// The activity manager.
public PluginUninstalledLogger(ILocalizationManager localizationManager, IActivityManager activityManager)
{
_localizationManager = localizationManager;
_activityManager = activityManager;
}
///
public async Task OnEvent(PluginUninstalledEventArgs eventArgs)
{
await _activityManager.CreateAsync(new ActivityLog(
string.Format(
CultureInfo.InvariantCulture,
_localizationManager.GetLocalizedString("PluginUninstalledWithName"),
eventArgs.Argument.Name),
NotificationType.PluginUninstalled.ToString(),
Guid.Empty))
.ConfigureAwait(false);
}
}
}