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;
|
|
|
|
|
|
2022-10-10 14:06:59 +00:00
|
|
|
|
namespace Jellyfin.Plugin.Webhook.Notifiers;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// User deleted notifier.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class UserDeletedNotifier : IEventConsumer<UserDeletedEventArgs>
|
2021-01-07 18:57:02 +00:00
|
|
|
|
{
|
2022-10-10 14:06:59 +00:00
|
|
|
|
private readonly IServerApplicationHost _applicationHost;
|
|
|
|
|
private readonly IWebhookSender _webhookSender;
|
|
|
|
|
|
2021-01-07 18:57:02 +00:00
|
|
|
|
/// <summary>
|
2022-10-10 14:06:59 +00:00
|
|
|
|
/// Initializes a new instance of the <see cref="UserDeletedNotifier"/> class.
|
2021-01-07 18:57:02 +00:00
|
|
|
|
/// </summary>
|
2022-10-10 14:06:59 +00:00
|
|
|
|
/// <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
|
|
|
|
{
|
2022-10-10 14:06:59 +00:00
|
|
|
|
_applicationHost = applicationHost;
|
|
|
|
|
_webhookSender = webhookSender;
|
|
|
|
|
}
|
2021-01-07 18:57:02 +00:00
|
|
|
|
|
2022-10-10 14:06:59 +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
|
|
|
|
|
2022-10-10 14:06:59 +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
|
|
|
|
}
|