mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-10 23:42:36 -07:00
small cleanup #865
This commit is contained in:
parent
ecae241049
commit
e0018f63fa
38 changed files with 399 additions and 552 deletions
|
@ -1,18 +1,26 @@
|
|||
using System.Security.Principal;
|
||||
using Ombi.Core.Claims;
|
||||
using Ombi.Core.Claims;
|
||||
using Ombi.Core.Models.Requests;
|
||||
using Ombi.Core.Rule;
|
||||
using Ombi.Core.Rules;
|
||||
using Ombi.Store.Entities;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Principal;
|
||||
|
||||
namespace Ombi.Core.Engine.Interfaces
|
||||
{
|
||||
public abstract class BaseEngine
|
||||
{
|
||||
protected BaseEngine(IPrincipal user)
|
||||
protected BaseEngine(IPrincipal user, IRuleEvaluator rules)
|
||||
{
|
||||
User = user;
|
||||
Rules = rules;
|
||||
}
|
||||
|
||||
|
||||
protected IPrincipal User { get; }
|
||||
|
||||
protected IRuleEvaluator Rules { get; }
|
||||
|
||||
protected string Username => User.Identity.Name;
|
||||
|
||||
protected bool HasRole(string roleName)
|
||||
|
@ -25,10 +33,7 @@ namespace Ombi.Core.Engine.Interfaces
|
|||
var sendNotification = !ShouldAutoApprove(type); /*|| !prSettings.IgnoreNotifyForAutoApprovedRequests;*/
|
||||
|
||||
if (HasRole(OmbiClaims.Admin))
|
||||
{
|
||||
sendNotification = false; // Don't bother sending a notification if the user is an admin
|
||||
|
||||
}
|
||||
return sendNotification;
|
||||
}
|
||||
|
||||
|
@ -43,13 +48,19 @@ namespace Ombi.Core.Engine.Interfaces
|
|||
{
|
||||
case RequestType.Movie:
|
||||
return HasRole(OmbiClaims.AutoApproveMovie);
|
||||
|
||||
case RequestType.TvShow:
|
||||
return HasRole(OmbiClaims.AutoApproveTv);
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public IEnumerable<RuleResult> RunRules(BaseRequestModel model)
|
||||
{
|
||||
var ruleResults = Rules.StartRequestRules(model).ToList();
|
||||
return ruleResults;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue