#1462 #865 Had to refactor how we use notificaitons. So we now have more notification fields about the request

This commit is contained in:
Jamie.Rees 2017-07-05 13:04:26 +01:00
parent b69b322bd5
commit b52a57b117
21 changed files with 256 additions and 112 deletions

View file

@ -1,7 +1,6 @@
using Ombi.Core.Claims;
using Ombi.Core.Rule;
using Ombi.Core.Rules;
using Ombi.Store.Entities;
using System.Collections.Generic;
using System.Security.Principal;
using System.Threading.Tasks;
@ -29,35 +28,15 @@ namespace Ombi.Core.Engine.Interfaces
return User.IsInRole(roleName);
}
protected bool ShouldSendNotification(RequestType type)
protected bool ShouldSendNotification(BaseRequest req)
{
var sendNotification = !ShouldAutoApprove(type); /*|| !prSettings.IgnoreNotifyForAutoApprovedRequests;*/
var sendNotification = !req.Approved; /*|| !prSettings.IgnoreNotifyForAutoApprovedRequests;*/
if (HasRole(OmbiClaims.Admin))
sendNotification = false; // Don't bother sending a notification if the user is an admin
return sendNotification;
}
public bool ShouldAutoApprove(RequestType requestType)
{
var admin = HasRole(OmbiClaims.Admin);
// if the user is an admin, they go ahead and allow auto-approval
if (admin) return true;
// check by request type if the category requires approval or not
switch (requestType)
{
case RequestType.Movie:
return HasRole(OmbiClaims.AutoApproveMovie);
case RequestType.TvShow:
return HasRole(OmbiClaims.AutoApproveTv);
default:
return false;
}
}
public async Task<IEnumerable<RuleResult>> RunRequestRules(BaseRequest model)
{
var ruleResults = await Rules.StartRequestRules(model);