From ab42723dc9853f1ff95da677b40d8c763a8b475a Mon Sep 17 00:00:00 2001 From: tidusjar Date: Fri, 17 Nov 2017 23:09:38 +0000 Subject: [PATCH] Fixed #1712 --- src/Ombi.Core/Engine/MovieRequestEngine.cs | 6 +++++- .../Rule/Rules/Specific/CanRequestRule.cs | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Ombi.Core/Engine/MovieRequestEngine.cs b/src/Ombi.Core/Engine/MovieRequestEngine.cs index 54733d76d..0a31f2d76 100644 --- a/src/Ombi.Core/Engine/MovieRequestEngine.cs +++ b/src/Ombi.Core/Engine/MovieRequestEngine.cs @@ -193,7 +193,11 @@ namespace Ombi.Core.Engine request.Denied = false; await MovieRepository.Update(request); - NotificationHelper.Notify(request, NotificationType.RequestApproved); + var canNotify = await RunSpecificRule(request, SpecificRules.CanSendNotification); + if (canNotify.Success) + { + NotificationHelper.Notify(request, NotificationType.RequestApproved); + } if (request.Approved) { diff --git a/src/Ombi.Core/Rule/Rules/Specific/CanRequestRule.cs b/src/Ombi.Core/Rule/Rules/Specific/CanRequestRule.cs index 524f4126a..d1293ca4a 100644 --- a/src/Ombi.Core/Rule/Rules/Specific/CanRequestRule.cs +++ b/src/Ombi.Core/Rule/Rules/Specific/CanRequestRule.cs @@ -2,6 +2,7 @@ using System.Threading.Tasks; using Ombi.Core.Rule.Interfaces; using Ombi.Helpers; +using Ombi.Store.Entities; using Ombi.Store.Entities.Requests; namespace Ombi.Core.Rule.Rules.Specific @@ -21,8 +22,23 @@ namespace Ombi.Core.Rule.Rules.Specific var req = (BaseRequest)obj; var sendNotification = !req.Approved; /*|| !prSettings.IgnoreNotifyForAutoApprovedRequests;*/ + if (req.RequestType == RequestType.Movie) + { + sendNotification = !User.IsInRole(OmbiRoles.AutoApproveMovie); + } + else if(req.RequestType == RequestType.TvShow) + { + sendNotification = !User.IsInRole(OmbiRoles.AutoApproveTv); + } + + if (User.IsInRole(OmbiRoles.Admin)) + { sendNotification = false; // Don't bother sending a notification if the user is an admin + } + + + return Task.FromResult(new RuleResult { Success = sendNotification