| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using System.Threading; |
| | 4 | | using System.Threading.Tasks; |
| | 5 | | using Jellyfin.Data.Events.Users; |
| | 6 | | using MediaBrowser.Controller.Events; |
| | 7 | | using MediaBrowser.Controller.Library; |
| | 8 | | using MediaBrowser.Controller.Session; |
| | 9 | | using MediaBrowser.Model.Session; |
| | 10 | |
|
| | 11 | | namespace Jellyfin.Server.Implementations.Events.Consumers.Users |
| | 12 | | { |
| | 13 | | /// <summary> |
| | 14 | | /// Notifies a user when their account has been updated. |
| | 15 | | /// </summary> |
| | 16 | | public class UserUpdatedNotifier : IEventConsumer<UserUpdatedEventArgs> |
| | 17 | | { |
| | 18 | | private readonly IUserManager _userManager; |
| | 19 | | private readonly ISessionManager _sessionManager; |
| | 20 | |
|
| | 21 | | /// <summary> |
| | 22 | | /// Initializes a new instance of the <see cref="UserUpdatedNotifier"/> class. |
| | 23 | | /// </summary> |
| | 24 | | /// <param name="userManager">The user manager.</param> |
| | 25 | | /// <param name="sessionManager">The session manager.</param> |
| | 26 | | public UserUpdatedNotifier(IUserManager userManager, ISessionManager sessionManager) |
| | 27 | | { |
| 0 | 28 | | _userManager = userManager; |
| 0 | 29 | | _sessionManager = sessionManager; |
| 0 | 30 | | } |
| | 31 | |
|
| | 32 | | /// <inheritdoc /> |
| | 33 | | public async Task OnEvent(UserUpdatedEventArgs eventArgs) |
| | 34 | | { |
| | 35 | | await _sessionManager.SendMessageToUserSessions( |
| | 36 | | new List<Guid> { eventArgs.Argument.Id }, |
| | 37 | | SessionMessageType.UserUpdated, |
| | 38 | | _userManager.GetUserDto(eventArgs.Argument), |
| | 39 | | CancellationToken.None).ConfigureAwait(false); |
| | 40 | | } |
| | 41 | | } |
| | 42 | | } |