diff options
| author | Patrick Barron <barronpm@gmail.com> | 2020-08-14 15:21:17 -0400 |
|---|---|---|
| committer | Patrick Barron <barronpm@gmail.com> | 2020-08-14 15:21:17 -0400 |
| commit | b7f21971f43d6d9f956ff0aade31625d3995858a (patch) | |
| tree | 62a7ccac56e77c7ec91b0c6565f33527d3c37f74 /Jellyfin.Server.Implementations/Events | |
| parent | f4275adfcb4c7c5e2daedbad09c64c04fc1ebc53 (diff) | |
Migrate ActivityLogEntryPoint.OnPluginInstalled to IEventConsumer
Diffstat (limited to 'Jellyfin.Server.Implementations/Events')
| -rw-r--r-- | Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginInstalledLogger.cs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginInstalledLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginInstalledLogger.cs new file mode 100644 index 000000000..8837172db --- /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); + } + } +} |
