Files
cleanuperr/code/Infrastructure/Verticals/Notifications/NotificationFactory.cs
T
2025-02-16 03:17:54 +02:00

32 lines
1.0 KiB
C#

namespace Infrastructure.Verticals.Notifications;
public class NotificationFactory : INotificationFactory
{
private readonly IEnumerable<INotificationProvider> _providers;
public NotificationFactory(IEnumerable<INotificationProvider> providers)
{
_providers = providers;
}
protected List<INotificationProvider> ActiveProviders() =>
_providers
.Where(x => x.Config.IsValid())
.Where(provider => provider.Config.IsEnabled)
.ToList();
public List<INotificationProvider> OnFailedImportStrikeEnabled() =>
ActiveProviders()
.Where(n => n.Config.OnImportFailedStrike)
.ToList();
public List<INotificationProvider> OnStalledStrikeEnabled() =>
ActiveProviders()
.Where(n => n.Config.OnStalledStrike)
.ToList();
public List<INotificationProvider> OnQueueItemDeleteEnabled() =>
ActiveProviders()
.Where(n => n.Config.OnQueueItemDelete)
.ToList();
}