using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Data.Events.Users;
using MediaBrowser.Controller.Events;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Session;
namespace Jellyfin.Server.Implementations.Events.Consumers.Users
{
///
/// Notifies a user when their account has been updated.
///
public class UserUpdatedNotifier : IEventConsumer
{
private readonly IUserManager _userManager;
private readonly ISessionManager _sessionManager;
///
/// Initializes a new instance of the class.
///
/// The user manager.
/// The session manager.
public UserUpdatedNotifier(IUserManager userManager, ISessionManager sessionManager)
{
_userManager = userManager;
_sessionManager = sessionManager;
}
///
public async Task OnEvent(UserUpdatedEventArgs e)
{
await _sessionManager.SendMessageToUserSessions(
new List { e.Argument.Id },
SessionMessageType.UserUpdated,
_userManager.GetUserDto(e.Argument),
CancellationToken.None).ConfigureAwait(false);
}
}
}