using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Data.Events.Users;
using MediaBrowser.Controller.Events;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Session;
namespace Jellyfin.Server.Implementations.Events.Consumers.Users
{
///
/// Notifies the user's sessions when a user is deleted.
///
public class UserDeletedNotifier : IEventConsumer
{
private readonly ISessionManager _sessionManager;
///
/// Initializes a new instance of the class.
///
/// The session manager.
public UserDeletedNotifier(ISessionManager sessionManager)
{
_sessionManager = sessionManager;
}
///
public async Task OnEvent(UserDeletedEventArgs eventArgs)
{
await _sessionManager.SendMessageToUserSessions(
new List { eventArgs.Argument.Id },
SessionMessageType.UserDeleted,
eventArgs.Argument.Id.ToString("N", CultureInfo.InvariantCulture),
CancellationToken.None).ConfigureAwait(false);
}
}
}