Skip to content

Commit

Permalink
#27 fully finished
Browse files Browse the repository at this point in the history
  • Loading branch information
tidusjar committed May 20, 2016
1 parent e1ca857 commit 7ce0502
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion PlexRequests.UI/Modules/SearchModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public SearchModule(ICacheProvider cache, ISettingsService<CouchPotatoSettings>
ISettingsService<SickRageSettings> sickRageService, ICouchPotatoApi cpApi, ISickRageApi srApi,
INotificationService notify, IMusicBrainzApi mbApi, IHeadphonesApi hpApi, ISettingsService<HeadphonesSettings> hpService,
ICouchPotatoCacher cpCacher, ISonarrCacher sonarrCacher, ISickRageCacher sickRageCacher, IPlexApi plexApi,
ISettingsService<PlexSettings> plexService, ISettingsService<AuthenticationSettings> auth, IRepository<UsersToNotify> u) : base("search", prSettings)
ISettingsService<PlexSettings> plexService, ISettingsService<AuthenticationSettings> auth, IRepository<UsersToNotify> u, ISettingsService<EmailNotificationSettings> email) : base("search", prSettings)
{
Auth = auth;
PlexService = plexService;
Expand All @@ -87,6 +87,7 @@ public SearchModule(ICacheProvider cache, ISettingsService<CouchPotatoSettings>
HeadphonesApi = hpApi;
HeadphonesService = hpService;
UsersToNotifyRepo = u;
EmailNotificationSettings = email;


Get["/"] = parameters => RequestLoad();
Expand Down Expand Up @@ -121,6 +122,7 @@ public SearchModule(ICacheProvider cache, ISettingsService<CouchPotatoSettings>
private ISettingsService<SonarrSettings> SonarrService { get; }
private ISettingsService<SickRageSettings> SickRageService { get; }
private ISettingsService<HeadphonesSettings> HeadphonesService { get; }
private ISettingsService<EmailNotificationSettings> EmailNotificationSettings { get; }
private IAvailabilityChecker Checker { get; }
private ICouchPotatoCacher CpCacher { get; }
private ISonarrCacher SonarrCacher { get; }
Expand Down Expand Up @@ -894,10 +896,15 @@ private bool ShouldAutoApprove(RequestType requestType, PlexRequestSettings prSe
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)
Expand Down

0 comments on commit 7ce0502

Please sign in to comment.