add an option to stop sending notifications for requests that don't require approval #345

This commit is contained in:
Drewster727 2016-06-21 19:43:31 -05:00
parent 4e10acbb51
commit 96f27f8f1a
5 changed files with 1595 additions and 1579 deletions

View file

@ -45,6 +45,7 @@ namespace PlexRequests.Core.SettingModels
public int WeeklyRequestLimit { get; set; } public int WeeklyRequestLimit { get; set; }
public string NoApprovalUsers { get; set; } public string NoApprovalUsers { get; set; }
public bool CollectAnalyticData { get; set; } public bool CollectAnalyticData { get; set; }
public bool IgnoreNotifyForAutoApprovedRequests { get; set; }
/// <summary> /// <summary>
/// The CSS name of the theme we want /// The CSS name of the theme we want

View file

@ -488,7 +488,7 @@ namespace PlexRequests.UI.Modules
Log.Info("Adding movie to database (No approval required)"); Log.Info("Adding movie to database (No approval required)");
await RequestService.AddRequestAsync(model); await RequestService.AddRequestAsync(model);
if (ShouldSendNotification()) if (ShouldSendNotification(settings))
{ {
var notificationModel = new NotificationModel var notificationModel = new NotificationModel
{ {
@ -515,7 +515,7 @@ namespace PlexRequests.UI.Modules
Log.Info("Adding movie to database (No approval required)"); Log.Info("Adding movie to database (No approval required)");
await RequestService.AddRequestAsync(model); await RequestService.AddRequestAsync(model);
if (ShouldSendNotification()) if (ShouldSendNotification(settings))
{ {
var notificationModel = new NotificationModel var notificationModel = new NotificationModel
{ {
@ -663,7 +663,7 @@ namespace PlexRequests.UI.Modules
Log.Debug("Adding tv to database requests (No approval required & Sonarr)"); Log.Debug("Adding tv to database requests (No approval required & Sonarr)");
await RequestService.AddRequestAsync(model); await RequestService.AddRequestAsync(model);
if (ShouldSendNotification()) if (ShouldSendNotification(settings))
{ {
var notify1 = new NotificationModel var notify1 = new NotificationModel
{ {
@ -691,7 +691,7 @@ namespace PlexRequests.UI.Modules
model.Approved = true; model.Approved = true;
Log.Debug("Adding tv to database requests (No approval required & SickRage)"); Log.Debug("Adding tv to database requests (No approval required & SickRage)");
await RequestService.AddRequestAsync(model); await RequestService.AddRequestAsync(model);
if (ShouldSendNotification()) if (ShouldSendNotification(settings))
{ {
var notify2 = new NotificationModel var notify2 = new NotificationModel
{ {
@ -713,7 +713,7 @@ namespace PlexRequests.UI.Modules
model.Approved = true; model.Approved = true;
Log.Debug("Adding tv to database requests (No approval required) and Sonarr/Sickrage not setup"); Log.Debug("Adding tv to database requests (No approval required) and Sonarr/Sickrage not setup");
await RequestService.AddRequestAsync(model); await RequestService.AddRequestAsync(model);
if (ShouldSendNotification()) if (ShouldSendNotification(settings))
{ {
var notify2 = new NotificationModel var notify2 = new NotificationModel
{ {
@ -739,9 +739,9 @@ namespace PlexRequests.UI.Modules
return Response.AsJson(new JsonResponseModel { Result = true, Message = $"{fullShowName} was successfully added!" }); return Response.AsJson(new JsonResponseModel { Result = true, Message = $"{fullShowName} was successfully added!" });
} }
private bool ShouldSendNotification() private bool ShouldSendNotification(PlexRequestSettings prSettings)
{ {
var sendNotification = true; var sendNotification = !prSettings.IgnoreNotifyForAutoApprovedRequests;
var claims = Context.CurrentUser?.Claims; var claims = Context.CurrentUser?.Claims;
if (claims != null) if (claims != null)
{ {
@ -838,7 +838,7 @@ namespace PlexRequests.UI.Modules
model.Approved = true; model.Approved = true;
await RequestService.AddRequestAsync(model); await RequestService.AddRequestAsync(model);
if (ShouldSendNotification()) if (ShouldSendNotification(settings))
{ {
var notify2 = new NotificationModel var notify2 = new NotificationModel
{ {
@ -858,7 +858,7 @@ namespace PlexRequests.UI.Modules
}); });
} }
if (ShouldSendNotification()) if (ShouldSendNotification(settings))
{ {
var notify2 = new NotificationModel var notify2 = new NotificationModel
{ {

View file

@ -194,6 +194,21 @@
</div> </div>
</div> </div>
<div class="form-group">
<div class="checkbox">
@if (Model.IgnoreNotifyForAutoApprovedRequests)
{
<input type="checkbox" id="IgnoreNotifyForAutoApprovedRequests" name="IgnoreNotifyForAutoApprovedRequests" checked="checked">
<label for="IgnoreNotifyForAutoApprovedRequests">Do not send notifications for requests that don't require approval</label>
}
else
{
<input type="checkbox" id="IgnoreNotifyForAutoApprovedRequests" name="IgnoreNotifyForAutoApprovedRequests"><label for="IgnoreNotifyForAutoApprovedRequests">Do not send notifications for requests that don't require approval</label>
}
</div>
</div>
<div class="form-group"> <div class="form-group">
<div class="checkbox"> <div class="checkbox">