mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
Lot's of refactoring
This commit is contained in:
parent
c6865d9dcc
commit
263240c648
36 changed files with 732 additions and 660 deletions
32
src/Ombi.Core/Rule/Rules/Specific/CanRequestRule.cs
Normal file
32
src/Ombi.Core/Rule/Rules/Specific/CanRequestRule.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using System.Security.Principal;
|
||||
using System.Threading.Tasks;
|
||||
using Ombi.Core.Claims;
|
||||
using Ombi.Core.Rule.Interfaces;
|
||||
using Ombi.Store.Entities.Requests;
|
||||
|
||||
namespace Ombi.Core.Rule.Rules.Specific
|
||||
{
|
||||
public class SendNotificationRule : SpecificRule, ISpecificRule<object>
|
||||
{
|
||||
public SendNotificationRule(IPrincipal principal)
|
||||
{
|
||||
User = principal;
|
||||
}
|
||||
|
||||
public override SpecificRules Rule => SpecificRules.CanSendNotification;
|
||||
private IPrincipal User { get; }
|
||||
|
||||
public Task<RuleResult> Execute(object obj)
|
||||
{
|
||||
var req = (BaseRequest)obj;
|
||||
var sendNotification = !req.Approved; /*|| !prSettings.IgnoreNotifyForAutoApprovedRequests;*/
|
||||
|
||||
if (User.IsInRole(OmbiClaims.Admin))
|
||||
sendNotification = false; // Don't bother sending a notification if the user is an admin
|
||||
return Task.FromResult(new RuleResult
|
||||
{
|
||||
Success = sendNotification
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue