mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-11 07:46:05 -07:00
The move!
This commit is contained in:
parent
1daf480b1b
commit
25526cc4d9
1147 changed files with 85 additions and 8524 deletions
55
src/Ombi.Core/Engine/Interfaces/BaseEngine.cs
Normal file
55
src/Ombi.Core/Engine/Interfaces/BaseEngine.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
using System.Security.Principal;
|
||||
using Ombi.Core.Claims;
|
||||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Core.Engine.Interfaces
|
||||
{
|
||||
public abstract class BaseEngine
|
||||
{
|
||||
protected BaseEngine(IPrincipal user)
|
||||
{
|
||||
User = user;
|
||||
}
|
||||
|
||||
protected IPrincipal User { get; }
|
||||
|
||||
protected string Username => User.Identity.Name;
|
||||
|
||||
protected bool HasRole(string roleName)
|
||||
{
|
||||
return User.IsInRole(roleName);
|
||||
}
|
||||
|
||||
protected bool ShouldSendNotification(RequestType type)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue