#nullable enable
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using BTCPayServer.Client.Models;
using BTCPayServer.Data;
using BTCPayServer.HostedServices;
using BTCPayServer.Plugins.Emails;
using BTCPayServer.Plugins.Emails.HostedServices;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using StoreData = BTCPayServer.Data.StoreData;
namespace BTCPayServer.Plugins.Webhooks.HostedServices;
///
/// This class listen to events and create webhook notifications and trigger event from it.
///
public class WebhookProviderHostedService(
EventAggregator eventAggregator,
ApplicationDbContextFactory dbContextFactory,
IEnumerable webhookTriggerProviders,
WebhookSender webhookSender,
ILogger logger)
: EventHostedServiceBase(eventAggregator, logger)
{
class WebhookTriggerOwner(WebhookTriggerProvider provider, WebhookTriggerContext ctx) : ITriggerOwner
{
public Task BeforeSending(EmailRuleMatchContext context)
=> provider.BeforeSending(context, ctx);
}
protected override void SubscribeToEvents()
{
SubscribeAny