jellyfin/Jellyfin.Server.Implementations/Events/Consumers/Users/UserDeletedLogger.cs

45 lines
1.6 KiB
C#
Raw Normal View History

using System;
using System.Globalization;
using System.Threading.Tasks;
using Jellyfin.Data.Entities;
using Jellyfin.Data.Events.Users;
using MediaBrowser.Controller.Events;
using MediaBrowser.Model.Activity;
using MediaBrowser.Model.Globalization;
namespace Jellyfin.Server.Implementations.Events.Consumers.Users
{
2020-08-15 00:35:42 -07:00
/// <summary>
/// Adds an entry to the activity log when a user is deleted.
/// </summary>
public class UserDeletedLogger : IEventConsumer<UserDeletedEventArgs>
{
private readonly ILocalizationManager _localizationManager;
private readonly IActivityManager _activityManager;
2020-08-15 00:35:42 -07:00
/// <summary>
/// Initializes a new instance of the <see cref="UserDeletedLogger"/> class.
/// </summary>
/// <param name="localizationManager">The localization manager.</param>
/// <param name="activityManager">The activity manager.</param>
public UserDeletedLogger(ILocalizationManager localizationManager, IActivityManager activityManager)
{
_localizationManager = localizationManager;
_activityManager = activityManager;
}
2020-08-15 00:35:42 -07:00
/// <inheritdoc />
public async Task OnEvent(UserDeletedEventArgs eventArgs)
{
await _activityManager.CreateAsync(new ActivityLog(
string.Format(
CultureInfo.InvariantCulture,
_localizationManager.GetLocalizedString("UserDeletedWithName"),
eventArgs.Argument.Username),
"UserDeleted",
Guid.Empty))
.ConfigureAwait(false);
}
}
}