jellyfin-plugin-webhook/Jellyfin.Plugin.Webhook/Notifiers/UserDeletedNotifier.cs

42 lines
1.4 KiB
C#
Raw Permalink Normal View History

2021-01-07 18:57:02 +00:00
using System.Threading.Tasks;
using Jellyfin.Data.Events.Users;
using Jellyfin.Plugin.Webhook.Destinations;
using Jellyfin.Plugin.Webhook.Helpers;
2021-11-11 15:22:12 +00:00
using MediaBrowser.Controller;
2021-01-07 18:57:02 +00:00
using MediaBrowser.Controller.Events;
namespace Jellyfin.Plugin.Webhook.Notifiers;
/// <summary>
/// User deleted notifier.
/// </summary>
public class UserDeletedNotifier : IEventConsumer<UserDeletedEventArgs>
2021-01-07 18:57:02 +00:00
{
private readonly IServerApplicationHost _applicationHost;
private readonly IWebhookSender _webhookSender;
2021-01-07 18:57:02 +00:00
/// <summary>
/// Initializes a new instance of the <see cref="UserDeletedNotifier"/> class.
2021-01-07 18:57:02 +00:00
/// </summary>
/// <param name="applicationHost">Instance of the <see cref="IServerApplicationHost"/> interface.</param>
/// <param name="webhookSender">Instance of the <see cref="IWebhookSender"/> interface.</param>
public UserDeletedNotifier(
IServerApplicationHost applicationHost,
IWebhookSender webhookSender)
2021-01-07 18:57:02 +00:00
{
_applicationHost = applicationHost;
_webhookSender = webhookSender;
}
2021-01-07 18:57:02 +00:00
/// <inheritdoc />
public async Task OnEvent(UserDeletedEventArgs eventArgs)
{
var dataObject = DataObjectHelpers
.GetBaseDataObject(_applicationHost, NotificationType.UserDeleted)
.AddUserData(eventArgs.Argument);
2021-01-07 18:57:02 +00:00
await _webhookSender.SendNotification(NotificationType.UserDeleted, dataObject)
.ConfigureAwait(false);
2021-01-07 18:57:02 +00:00
}
2021-11-11 15:22:12 +00:00
}