mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-30 19:40:05 -07:00
Rules changes and rework
This commit is contained in:
parent
d5ec429893
commit
9f4a8902f9
32 changed files with 2804 additions and 35 deletions
34
src/Ombi.Core/Rule/Rules/Request/AutoApproveRule.cs
Normal file
34
src/Ombi.Core/Rule/Rules/Request/AutoApproveRule.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using Ombi.Core.Claims;
|
||||
using Ombi.Core.Models.Requests;
|
||||
using Ombi.Core.Rules;
|
||||
using Ombi.Store.Entities;
|
||||
using System.Security.Principal;
|
||||
using Ombi.Core.Rule.Interfaces;
|
||||
|
||||
namespace Ombi.Core.Rule.Rules
|
||||
{
|
||||
public class AutoApproveRule : BaseRequestRule, IRequestRules<BaseRequestModel>
|
||||
{
|
||||
public AutoApproveRule(IPrincipal principal)
|
||||
{
|
||||
User = principal;
|
||||
}
|
||||
|
||||
private IPrincipal User { get; }
|
||||
|
||||
public RuleResult Execute(BaseRequestModel obj)
|
||||
{
|
||||
if (User.IsInRole(OmbiClaims.Admin))
|
||||
{
|
||||
obj.Approved = true;
|
||||
return Success();
|
||||
}
|
||||
|
||||
if (obj.Type == RequestType.Movie && User.IsInRole(OmbiClaims.AutoApproveMovie))
|
||||
obj.Approved = true;
|
||||
if (obj.Type == RequestType.TvShow && User.IsInRole(OmbiClaims.AutoApproveTv))
|
||||
obj.Approved = true;
|
||||
return Success(); // We don't really care, we just don't set the obj to approve
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue