diff --git a/NzbDrone.Api/Commands/CommandModule.cs b/NzbDrone.Api/Commands/CommandModule.cs index b5d2c2c59..cddbd414d 100644 --- a/NzbDrone.Api/Commands/CommandModule.cs +++ b/NzbDrone.Api/Commands/CommandModule.cs @@ -24,6 +24,8 @@ namespace NzbDrone.Api.Commands private CommandResource RunCommand(CommandResource resource) { + _messageAggregator.PublishEvent(new EpisodeGrabbedEvent(new RemoteEpisode())); + var commandType = _container.GetImplementations(typeof(ICommand)) .Single(c => c.Name.Replace("Command", "") diff --git a/NzbDrone.Core/Notifications/Growl/Growl.cs b/NzbDrone.Core/Notifications/Growl/Growl.cs index 2f6dfc7f2..5420ceabd 100644 --- a/NzbDrone.Core/Notifications/Growl/Growl.cs +++ b/NzbDrone.Core/Notifications/Growl/Growl.cs @@ -5,7 +5,7 @@ using NzbDrone.Core.Tv; namespace NzbDrone.Core.Notifications.Growl { - public class Growl : NotificationWithSetting + public class Growl : NotificationBase { private readonly GrowlProvider _growlProvider; diff --git a/NzbDrone.Core/Notifications/INotifcationSettings.cs b/NzbDrone.Core/Notifications/INotifcationSettings.cs index 93770d959..50c9caa88 100644 --- a/NzbDrone.Core/Notifications/INotifcationSettings.cs +++ b/NzbDrone.Core/Notifications/INotifcationSettings.cs @@ -9,22 +9,4 @@ namespace NzbDrone.Core.Notifications { bool IsValid { get; } } - - public class NullSetting : INotifcationSettings - { - public static NullSetting Instance = new NullSetting(); - - private NullSetting() - { - - } - - public bool IsValid - { - get - { - return true; - } - } - } } diff --git a/NzbDrone.Core/Notifications/NotificationBase.cs b/NzbDrone.Core/Notifications/NotificationBase.cs index be9377725..264716fe1 100644 --- a/NzbDrone.Core/Notifications/NotificationBase.cs +++ b/NzbDrone.Core/Notifications/NotificationBase.cs @@ -1,10 +1,11 @@ using System; using NLog; +using NzbDrone.Common.Serializer; using NzbDrone.Core.Tv; namespace NzbDrone.Core.Notifications { - public abstract class NotificationBase : INotification + public abstract class NotificationBase : INotification where TSetting : class, INotifcationSettings, new() { public abstract string Name { get; } @@ -13,5 +14,14 @@ namespace NzbDrone.Core.Notifications public abstract void OnGrab(string message); public abstract void OnDownload(string message, Series series); public abstract void AfterRename(Series series); + + public TSetting Settings { get; private set; } + + public TSetting ImportSettingsFromJson(string json) + { + Settings = Json.Deserialize(json) ?? new TSetting(); + + return Settings; + } } } diff --git a/NzbDrone.Core/Notifications/NotificationService.cs b/NzbDrone.Core/Notifications/NotificationService.cs index b086cb378..d6f52757f 100644 --- a/NzbDrone.Core/Notifications/NotificationService.cs +++ b/NzbDrone.Core/Notifications/NotificationService.cs @@ -39,6 +39,7 @@ namespace NzbDrone.Core.Notifications public List All() { + var test = _notificationRepository.All();//.Select(ToNotification).ToList(); return _notificationRepository.All().Select(ToNotification).ToList(); } @@ -50,15 +51,7 @@ namespace NzbDrone.Core.Notifications notification.OnDownload = definition.OnDownload; notification.Instance = GetInstance(definition); notification.Name = definition.Name; - - if (notification.Instance.GetType().GetMethod("ImportSettingsFromJson") != null) - { - notification.Settings = ((dynamic)notification.Instance).ImportSettingsFromJson(definition.Settings); - } - else - { - notification.Settings = NullSetting.Instance; - } + notification.Settings = ((dynamic)notification.Instance).ImportSettingsFromJson(definition.Settings); return notification; } diff --git a/NzbDrone.Core/Notifications/NotificationWithSetting.cs b/NzbDrone.Core/Notifications/NotificationWithSetting.cs deleted file mode 100644 index 109310c75..000000000 --- a/NzbDrone.Core/Notifications/NotificationWithSetting.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using NzbDrone.Common.Serializer; - -namespace NzbDrone.Core.Notifications -{ - public abstract class NotificationWithSetting : NotificationBase where TSetting : class, INotifcationSettings, new() - { - public TSetting Settings { get; private set; } - - public TSetting ImportSettingsFromJson(string json) - { - Settings = Json.Deserialize(json) ?? new TSetting(); - - return Settings; - } - } -} diff --git a/NzbDrone.Core/Notifications/Plex/PlexClient.cs b/NzbDrone.Core/Notifications/Plex/PlexClient.cs index 8640f9ecc..d9089e2d5 100644 --- a/NzbDrone.Core/Notifications/Plex/PlexClient.cs +++ b/NzbDrone.Core/Notifications/Plex/PlexClient.cs @@ -4,7 +4,7 @@ using NzbDrone.Core.Tv; namespace NzbDrone.Core.Notifications.Plex { - public class PlexClient : NotificationWithSetting + public class PlexClient : NotificationBase { private readonly PlexProvider _plexProvider; diff --git a/NzbDrone.Core/Notifications/Plex/PlexServer.cs b/NzbDrone.Core/Notifications/Plex/PlexServer.cs index 5b707efe1..f92271879 100644 --- a/NzbDrone.Core/Notifications/Plex/PlexServer.cs +++ b/NzbDrone.Core/Notifications/Plex/PlexServer.cs @@ -4,7 +4,7 @@ using NzbDrone.Core.Tv; namespace NzbDrone.Core.Notifications.Plex { - public class PlexServer : NotificationWithSetting + public class PlexServer : NotificationBase { private readonly PlexProvider _plexProvider; diff --git a/NzbDrone.Core/Notifications/Prowl/Prowl.cs b/NzbDrone.Core/Notifications/Prowl/Prowl.cs index be4dc6997..a0d96d723 100644 --- a/NzbDrone.Core/Notifications/Prowl/Prowl.cs +++ b/NzbDrone.Core/Notifications/Prowl/Prowl.cs @@ -3,7 +3,7 @@ using Prowlin; namespace NzbDrone.Core.Notifications.Prowl { - public class Prowl : NotificationWithSetting + public class Prowl : NotificationBase { private readonly ProwlProvider _prowlProvider; diff --git a/NzbDrone.Core/Notifications/Prowl/ProwlSettings.cs b/NzbDrone.Core/Notifications/Prowl/ProwlSettings.cs index 7dd087d8b..0fb9150d8 100644 --- a/NzbDrone.Core/Notifications/Prowl/ProwlSettings.cs +++ b/NzbDrone.Core/Notifications/Prowl/ProwlSettings.cs @@ -12,13 +12,13 @@ namespace NzbDrone.Core.Notifications.Prowl public String ApiKey { get; set; } [FieldDefinition(1, Label = "Priority", HelpText = "Priority to send messages at")] - public Int32 Priority { get; set; } + public Nullable Priority { get; set; } public bool IsValid { get { - return !string.IsNullOrWhiteSpace(ApiKey) && Priority > 0; + return !string.IsNullOrWhiteSpace(ApiKey) && Priority != null & Priority >= -2 && Priority <= 2; } } } diff --git a/NzbDrone.Core/Notifications/Smtp/Smtp.cs b/NzbDrone.Core/Notifications/Smtp/Smtp.cs index aadec4a59..104c9bc21 100644 --- a/NzbDrone.Core/Notifications/Smtp/Smtp.cs +++ b/NzbDrone.Core/Notifications/Smtp/Smtp.cs @@ -5,7 +5,7 @@ using NzbDrone.Core.Tv; namespace NzbDrone.Core.Notifications.Smtp { - public class Smtp : NotificationWithSetting + public class Smtp : NotificationBase { private readonly SmtpProvider _smtpProvider; diff --git a/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs b/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs index f6bbc446b..514a5dd0e 100644 --- a/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs +++ b/NzbDrone.Core/Notifications/Xbmc/Xbmc.cs @@ -3,7 +3,7 @@ using NzbDrone.Core.Tv; namespace NzbDrone.Core.Notifications.Xbmc { - public class Xbmc : NotificationWithSetting + public class Xbmc : NotificationBase { private readonly XbmcProvider _xbmcProvider; diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 9a04907ce..50bbb1da9 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -313,7 +313,6 @@ - diff --git a/NzbDrone/MainAppContainerBuilder.cs b/NzbDrone/MainAppContainerBuilder.cs index 82951d05f..540ad56c6 100644 --- a/NzbDrone/MainAppContainerBuilder.cs +++ b/NzbDrone/MainAppContainerBuilder.cs @@ -8,7 +8,6 @@ using NzbDrone.Common.Composition; using NzbDrone.Common.Messaging; using NzbDrone.Core.Datastore; using NzbDrone.Core.Instrumentation; -using NzbDrone.Core.Notifications; using NzbDrone.Core.Organizer; using NzbDrone.Core.RootFolders; @@ -27,7 +26,6 @@ namespace NzbDrone private MainAppContainerBuilder() : base("NzbDrone", "NzbDrone.Common", "NzbDrone.Core", "NzbDrone.Api") { - AutoRegisterImplementations(); AutoRegisterImplementations(); Container.Register(typeof(IBasicRepository), typeof(BasicRepository)); @@ -36,9 +34,6 @@ namespace NzbDrone Container.Register(); InitDatabase(); - - - } private void InitDatabase()