From 7ce05028fcf523c8c0ba5c2b907f111cc9f23c12 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Fri, 20 May 2016 21:52:06 +0100 Subject: [PATCH] #27 fully finished --- PlexRequests.UI/Modules/SearchModule.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/PlexRequests.UI/Modules/SearchModule.cs b/PlexRequests.UI/Modules/SearchModule.cs index 31f875453..29a39fa37 100644 --- a/PlexRequests.UI/Modules/SearchModule.cs +++ b/PlexRequests.UI/Modules/SearchModule.cs @@ -63,7 +63,7 @@ namespace PlexRequests.UI.Modules ISettingsService sickRageService, ICouchPotatoApi cpApi, ISickRageApi srApi, INotificationService notify, IMusicBrainzApi mbApi, IHeadphonesApi hpApi, ISettingsService hpService, ICouchPotatoCacher cpCacher, ISonarrCacher sonarrCacher, ISickRageCacher sickRageCacher, IPlexApi plexApi, - ISettingsService plexService, ISettingsService auth, IRepository u) : base("search", prSettings) + ISettingsService plexService, ISettingsService auth, IRepository u, ISettingsService email) : base("search", prSettings) { Auth = auth; PlexService = plexService; @@ -87,6 +87,7 @@ namespace PlexRequests.UI.Modules HeadphonesApi = hpApi; HeadphonesService = hpService; UsersToNotifyRepo = u; + EmailNotificationSettings = email; Get["/"] = parameters => RequestLoad(); @@ -121,6 +122,7 @@ namespace PlexRequests.UI.Modules private ISettingsService SonarrService { get; } private ISettingsService SickRageService { get; } private ISettingsService HeadphonesService { get; } + private ISettingsService EmailNotificationSettings { get; } private IAvailabilityChecker Checker { get; } private ICouchPotatoCacher CpCacher { get; } private ISonarrCacher SonarrCacher { get; } @@ -894,10 +896,15 @@ namespace PlexRequests.UI.Modules private Response NotifyUser(bool notify) { var auth = Auth.GetSettings().UserAuthentication; + var email = EmailNotificationSettings.GetSettings().EnableUserEmailNotifications; if (!auth) { return Response.AsJson(new JsonResponseModel { Result = false, Message = "Sorry, but this functionality is currently only for users with Plex accounts"}); } + if (!email) + { + return Response.AsJson(new JsonResponseModel { Result = false, Message = "Sorry, but your administrator has not yet enabled this functionality." }); + } var username = Username; var originalList = UsersToNotifyRepo.GetAll(); if (!notify)