Lot's of refactoring

This commit is contained in:
Jamie.Rees 2017-07-06 16:24:51 +01:00
parent c6865d9dcc
commit 263240c648
36 changed files with 732 additions and 660 deletions

View 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
});
}
}
}