Migrate ActivityLogEntryPoint.OnPluginUpdated to IEventConsumer

pull/3910/head
Patrick Barron 4 years ago
parent 0da7c0568d
commit e924444880

@ -8,7 +8,6 @@ using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Activity;
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.Notifications;
using MediaBrowser.Model.Updates;
namespace Emby.Server.Implementations.Activity
{
@ -44,7 +43,6 @@ namespace Emby.Server.Implementations.Activity
/// <inheritdoc />
public Task RunAsync()
{
_installationManager.PluginUpdated += OnPluginUpdated;
_installationManager.PackageInstallationFailed += OnPackageInstallationFailed;
_sessionManager.SessionStarted += OnSessionStarted;
@ -103,24 +101,6 @@ namespace Emby.Server.Implementations.Activity
}).ConfigureAwait(false);
}
private async void OnPluginUpdated(object sender, InstallationInfo e)
{
await CreateLogEntry(new ActivityLog(
string.Format(
CultureInfo.InvariantCulture,
_localization.GetLocalizedString("PluginUpdatedWithName"),
e.Name),
NotificationType.PluginUpdateInstalled.ToString(),
Guid.Empty)
{
ShortOverview = string.Format(
CultureInfo.InvariantCulture,
_localization.GetLocalizedString("VersionNumber"),
e.Version),
Overview = e.Changelog
}).ConfigureAwait(false);
}
private async void OnPackageInstallationFailed(object sender, InstallationFailedEventArgs e)
{
var installationInfo = e.InstallationInfo;
@ -147,7 +127,6 @@ namespace Emby.Server.Implementations.Activity
/// <inheritdoc />
public void Dispose()
{
_installationManager.PluginUpdated -= OnPluginUpdated;
_installationManager.PackageInstallationFailed -= OnPackageInstallationFailed;
_sessionManager.SessionStarted -= OnSessionStarted;

@ -0,0 +1,51 @@
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 updated.
/// </summary>
public class PluginUpdatedLogger : IEventConsumer<PluginUpdatedEventArgs>
{
private readonly ILocalizationManager _localizationManager;
private readonly IActivityManager _activityManager;
/// <summary>
/// Initializes a new instance of the <see cref="PluginUpdatedLogger"/> class.
/// </summary>
/// <param name="localizationManager">The localization manager.</param>
/// <param name="activityManager">The activity manager.</param>
public PluginUpdatedLogger(ILocalizationManager localizationManager, IActivityManager activityManager)
{
_localizationManager = localizationManager;
_activityManager = activityManager;
}
/// <inheritdoc />
public async Task OnEvent(PluginUpdatedEventArgs eventArgs)
{
await _activityManager.CreateAsync(new ActivityLog(
string.Format(
CultureInfo.InvariantCulture,
_localizationManager.GetLocalizedString("PluginUpdatedWithName"),
eventArgs.Argument.Name),
NotificationType.PluginUpdateInstalled.ToString(),
Guid.Empty)
{
ShortOverview = string.Format(
CultureInfo.InvariantCulture,
_localizationManager.GetLocalizedString("VersionNumber"),
eventArgs.Argument.Version),
Overview = eventArgs.Argument.Changelog
}).ConfigureAwait(false);
}
}
}

@ -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 updated.
/// </summary>
public class PluginUpdatedEventArgs : GenericEventArgs<InstallationInfo>
{
/// <summary>
/// Initializes a new instance of the <see cref="PluginUpdatedEventArgs"/> class.
/// </summary>
/// <param name="arg">The installation info.</param>
public PluginUpdatedEventArgs(InstallationInfo arg) : base(arg)
{
}
}
}
Loading…
Cancel
Save