2021-10-21 20:04:26 +00:00
|
|
|
using System;
|
2021-03-05 23:30:08 +00:00
|
|
|
using System.Collections.Generic;
|
2013-10-13 02:46:36 +00:00
|
|
|
using System.Linq;
|
2013-10-12 18:44:40 +00:00
|
|
|
using NLog;
|
2013-10-13 02:46:36 +00:00
|
|
|
using NzbDrone.Common.Composition;
|
2014-02-26 05:40:47 +00:00
|
|
|
using NzbDrone.Core.Messaging.Events;
|
2013-10-12 18:44:40 +00:00
|
|
|
using NzbDrone.Core.ThingiProvider;
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Notifications
|
|
|
|
{
|
|
|
|
public interface INotificationFactory : IProviderFactory<INotification, NotificationDefinition>
|
|
|
|
{
|
2013-10-13 02:46:36 +00:00
|
|
|
List<INotification> OnGrabEnabled();
|
|
|
|
List<INotification> OnDownloadEnabled();
|
2014-02-11 01:09:31 +00:00
|
|
|
List<INotification> OnUpgradeEnabled();
|
2015-05-20 23:22:10 +00:00
|
|
|
List<INotification> OnRenameEnabled();
|
2021-03-05 23:30:08 +00:00
|
|
|
List<INotification> OnMovieDeleteEnabled();
|
|
|
|
List<INotification> OnMovieFileDeleteEnabled();
|
2019-11-04 20:44:33 +00:00
|
|
|
List<INotification> OnHealthIssueEnabled();
|
2013-10-12 18:44:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public class NotificationFactory : ProviderFactory<INotification, NotificationDefinition>, INotificationFactory
|
|
|
|
{
|
2021-10-21 20:04:26 +00:00
|
|
|
public NotificationFactory(INotificationRepository providerRepository, IEnumerable<INotification> providers, IServiceProvider container, IEventAggregator eventAggregator, Logger logger)
|
2014-02-26 05:40:47 +00:00
|
|
|
: base(providerRepository, providers, container, eventAggregator, logger)
|
2013-10-12 18:44:40 +00:00
|
|
|
{
|
2013-10-13 02:46:36 +00:00
|
|
|
}
|
2013-10-12 18:44:40 +00:00
|
|
|
|
2013-10-13 02:46:36 +00:00
|
|
|
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();
|
2013-10-12 18:44:40 +00:00
|
|
|
}
|
2014-02-11 01:09:31 +00:00
|
|
|
|
|
|
|
public List<INotification> OnUpgradeEnabled()
|
|
|
|
{
|
|
|
|
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnUpgrade).ToList();
|
|
|
|
}
|
2015-05-20 23:22:10 +00:00
|
|
|
|
|
|
|
public List<INotification> OnRenameEnabled()
|
|
|
|
{
|
|
|
|
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnRename).ToList();
|
|
|
|
}
|
|
|
|
|
2021-03-05 23:30:08 +00:00
|
|
|
public List<INotification> OnMovieDeleteEnabled()
|
2019-11-04 20:44:33 +00:00
|
|
|
{
|
2021-03-05 23:30:08 +00:00
|
|
|
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnMovieDelete).ToList();
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<INotification> OnMovieFileDeleteEnabled()
|
|
|
|
{
|
|
|
|
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnMovieFileDelete).ToList();
|
2019-11-04 20:44:33 +00:00
|
|
|
}
|
|
|
|
|
2021-03-05 23:30:08 +00:00
|
|
|
public List<INotification> OnMovieFileDeleteForUpgradeEnabled()
|
2020-08-16 04:32:53 +00:00
|
|
|
{
|
2021-03-05 23:30:08 +00:00
|
|
|
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnMovieFileDeleteForUpgrade).ToList();
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<INotification> OnHealthIssueEnabled()
|
|
|
|
{
|
|
|
|
return GetAvailableProviders().Where(n => ((NotificationDefinition)n.Definition).OnHealthIssue).ToList();
|
2020-08-16 04:32:53 +00:00
|
|
|
}
|
|
|
|
|
2016-03-25 00:56:29 +00:00
|
|
|
public override void SetProviderCharacteristics(INotification provider, NotificationDefinition definition)
|
2015-05-20 23:22:10 +00:00
|
|
|
{
|
2016-03-25 00:56:29 +00:00
|
|
|
base.SetProviderCharacteristics(provider, definition);
|
2015-05-20 23:22:10 +00:00
|
|
|
|
|
|
|
definition.SupportsOnGrab = provider.SupportsOnGrab;
|
|
|
|
definition.SupportsOnDownload = provider.SupportsOnDownload;
|
|
|
|
definition.SupportsOnUpgrade = provider.SupportsOnUpgrade;
|
|
|
|
definition.SupportsOnRename = provider.SupportsOnRename;
|
2021-03-05 23:30:08 +00:00
|
|
|
definition.SupportsOnMovieDelete = provider.SupportsOnMovieDelete;
|
|
|
|
definition.SupportsOnMovieFileDelete = provider.SupportsOnMovieFileDelete;
|
|
|
|
definition.SupportsOnMovieFileDeleteForUpgrade = provider.SupportsOnMovieFileDeleteForUpgrade;
|
2019-11-04 20:44:33 +00:00
|
|
|
definition.SupportsOnHealthIssue = provider.SupportsOnHealthIssue;
|
2015-05-20 23:22:10 +00:00
|
|
|
}
|
2013-10-12 18:44:40 +00:00
|
|
|
}
|
2019-12-22 21:24:10 +00:00
|
|
|
}
|