mirror of
https://github.com/Radarr/Radarr
synced 2026-04-13 15:41:37 +02:00
(cherry picked from commit d6170dbfedf27a6218afe242a0fae2eb8b368aec) (cherry picked from commit 7fe36a7e9222e830f4920e09a85115df0bdbf190)
83 lines
3.4 KiB
C#
83 lines
3.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using NLog;
|
|
using NzbDrone.Common.Composition;
|
|
using NzbDrone.Core.Messaging.Events;
|
|
using NzbDrone.Core.ThingiProvider;
|
|
|
|
namespace NzbDrone.Core.Notifications
|
|
{
|
|
public interface INotificationFactory : IProviderFactory<INotification, NotificationDefinition>
|
|
{
|
|
List<INotification> OnGrabEnabled();
|
|
List<INotification> OnDownloadEnabled();
|
|
List<INotification> OnUpgradeEnabled();
|
|
List<INotification> OnRenameEnabled();
|
|
List<INotification> OnMovieDeleteEnabled();
|
|
List<INotification> OnMovieFileDeleteEnabled();
|
|
List<INotification> OnHealthIssueEnabled();
|
|
}
|
|
|
|
public class NotificationFactory : ProviderFactory<INotification, NotificationDefinition>, INotificationFactory
|
|
{
|
|
public NotificationFactory(INotificationRepository providerRepository, IEnumerable<INotification> providers, IServiceProvider container, IEventAggregator eventAggregator, Logger logger)
|
|
: base(providerRepository, providers, container, eventAggregator, logger)
|
|
{
|
|
}
|
|
|
|
public List<INotification> OnGrabEnabled()
|
|
{
|
|
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnGrab).ToList();
|
|
}
|
|
|
|
public List<INotification> OnDownloadEnabled()
|
|
{
|
|
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnDownload).ToList();
|
|
}
|
|
|
|
public List<INotification> OnUpgradeEnabled()
|
|
{
|
|
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnUpgrade).ToList();
|
|
}
|
|
|
|
public List<INotification> OnRenameEnabled()
|
|
{
|
|
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnRename).ToList();
|
|
}
|
|
|
|
public List<INotification> OnMovieDeleteEnabled()
|
|
{
|
|
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnMovieDelete).ToList();
|
|
}
|
|
|
|
public List<INotification> OnMovieFileDeleteEnabled()
|
|
{
|
|
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnMovieFileDelete).ToList();
|
|
}
|
|
|
|
public List<INotification> OnMovieFileDeleteForUpgradeEnabled()
|
|
{
|
|
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnMovieFileDeleteForUpgrade).ToList();
|
|
}
|
|
|
|
public List<INotification> OnHealthIssueEnabled()
|
|
{
|
|
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnHealthIssue).ToList();
|
|
}
|
|
|
|
public override void SetProviderCharacteristics(INotification provider, NotificationDefinition definition)
|
|
{
|
|
base.SetProviderCharacteristics(provider, definition);
|
|
|
|
definition.SupportsOnGrab = provider.SupportsOnGrab;
|
|
definition.SupportsOnDownload = provider.SupportsOnDownload;
|
|
definition.SupportsOnUpgrade = provider.SupportsOnUpgrade;
|
|
definition.SupportsOnRename = provider.SupportsOnRename;
|
|
definition.SupportsOnMovieDelete = provider.SupportsOnMovieDelete;
|
|
definition.SupportsOnMovieFileDelete = provider.SupportsOnMovieFileDelete;
|
|
definition.SupportsOnMovieFileDeleteForUpgrade = provider.SupportsOnMovieFileDeleteForUpgrade;
|
|
definition.SupportsOnHealthIssue = provider.SupportsOnHealthIssue;
|
|
}
|
|
}
|
|
}
|