| | | 1 | | using System; |
| | | 2 | | using System.Globalization; |
| | | 3 | | using System.Threading.Tasks; |
| | | 4 | | using Jellyfin.Database.Implementations.Entities; |
| | | 5 | | using MediaBrowser.Controller.Events; |
| | | 6 | | using MediaBrowser.Controller.Events.Updates; |
| | | 7 | | using MediaBrowser.Model.Activity; |
| | | 8 | | using MediaBrowser.Model.Globalization; |
| | | 9 | | using MediaBrowser.Model.Notifications; |
| | | 10 | | |
| | | 11 | | namespace Jellyfin.Server.Implementations.Events.Consumers.Updates |
| | | 12 | | { |
| | | 13 | | /// <summary> |
| | | 14 | | /// Creates an entry in the activity log when a plugin is installed. |
| | | 15 | | /// </summary> |
| | | 16 | | public class PluginInstalledLogger : IEventConsumer<PluginInstalledEventArgs> |
| | | 17 | | { |
| | | 18 | | private readonly ILocalizationManager _localizationManager; |
| | | 19 | | private readonly IActivityManager _activityManager; |
| | | 20 | | |
| | | 21 | | /// <summary> |
| | | 22 | | /// Initializes a new instance of the <see cref="PluginInstalledLogger"/> class. |
| | | 23 | | /// </summary> |
| | | 24 | | /// <param name="localizationManager">The localization manager.</param> |
| | | 25 | | /// <param name="activityManager">The activity manager.</param> |
| | | 26 | | public PluginInstalledLogger(ILocalizationManager localizationManager, IActivityManager activityManager) |
| | | 27 | | { |
| | 0 | 28 | | _localizationManager = localizationManager; |
| | 0 | 29 | | _activityManager = activityManager; |
| | 0 | 30 | | } |
| | | 31 | | |
| | | 32 | | /// <inheritdoc /> |
| | | 33 | | public async Task OnEvent(PluginInstalledEventArgs eventArgs) |
| | | 34 | | { |
| | | 35 | | await _activityManager.CreateAsync(new ActivityLog( |
| | | 36 | | string.Format( |
| | | 37 | | CultureInfo.InvariantCulture, |
| | | 38 | | _localizationManager.GetLocalizedString("PluginInstalledWithName"), |
| | | 39 | | eventArgs.Argument.Name), |
| | | 40 | | NotificationType.PluginInstalled.ToString(), |
| | | 41 | | Guid.Empty) |
| | | 42 | | { |
| | | 43 | | ShortOverview = string.Format( |
| | | 44 | | CultureInfo.InvariantCulture, |
| | | 45 | | _localizationManager.GetLocalizedString("VersionNumber"), |
| | | 46 | | eventArgs.Argument.Version) |
| | | 47 | | }).ConfigureAwait(false); |
| | | 48 | | } |
| | | 49 | | } |
| | | 50 | | } |