| | 1 | | using System; |
| | 2 | | using System.Globalization; |
| | 3 | | using System.Threading.Tasks; |
| | 4 | | using Jellyfin.Data.Events.Users; |
| | 5 | | using Jellyfin.Database.Implementations.Entities; |
| | 6 | | using MediaBrowser.Controller.Events; |
| | 7 | | using MediaBrowser.Model.Activity; |
| | 8 | | using MediaBrowser.Model.Globalization; |
| | 9 | |
|
| | 10 | | namespace Jellyfin.Server.Implementations.Events.Consumers.Users |
| | 11 | | { |
| | 12 | | /// <summary> |
| | 13 | | /// Adds an entry to the activity log when a user is deleted. |
| | 14 | | /// </summary> |
| | 15 | | public class UserDeletedLogger : IEventConsumer<UserDeletedEventArgs> |
| | 16 | | { |
| | 17 | | private readonly ILocalizationManager _localizationManager; |
| | 18 | | private readonly IActivityManager _activityManager; |
| | 19 | |
|
| | 20 | | /// <summary> |
| | 21 | | /// Initializes a new instance of the <see cref="UserDeletedLogger"/> class. |
| | 22 | | /// </summary> |
| | 23 | | /// <param name="localizationManager">The localization manager.</param> |
| | 24 | | /// <param name="activityManager">The activity manager.</param> |
| | 25 | | public UserDeletedLogger(ILocalizationManager localizationManager, IActivityManager activityManager) |
| | 26 | | { |
| 0 | 27 | | _localizationManager = localizationManager; |
| 0 | 28 | | _activityManager = activityManager; |
| 0 | 29 | | } |
| | 30 | |
|
| | 31 | | /// <inheritdoc /> |
| | 32 | | public async Task OnEvent(UserDeletedEventArgs eventArgs) |
| | 33 | | { |
| | 34 | | await _activityManager.CreateAsync(new ActivityLog( |
| | 35 | | string.Format( |
| | 36 | | CultureInfo.InvariantCulture, |
| | 37 | | _localizationManager.GetLocalizedString("UserDeletedWithName"), |
| | 38 | | eventArgs.Argument.Username), |
| | 39 | | "UserDeleted", |
| | 40 | | Guid.Empty)) |
| | 41 | | .ConfigureAwait(false); |
| | 42 | | } |
| | 43 | | } |
| | 44 | | } |