From 8d5dfe9424d0286ccf0e04ca70269a00da5479f0 Mon Sep 17 00:00:00 2001 From: Jamie Date: Wed, 20 Dec 2017 16:23:47 +0000 Subject: [PATCH] #1659 Made the option to ignore notifcations for auto approve --- appveyor.yml | 2 ++ src/.vscode/src.code-workspace | 13 +++++++++++ src/.vscode/ui.code-workspace | 10 ++++++++ ...RequestRule.cs => SendNotificationRule.cs} | 23 ++++++++++++++----- .../Settings/Models/OmbiSettings.cs | 1 + .../ClientApp/app/interfaces/ISettings.ts | 1 + .../app/settings/ombi/ombi.component.html | 8 +++++++ .../app/settings/ombi/ombi.component.ts | 1 + 8 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 src/.vscode/src.code-workspace create mode 100644 src/.vscode/ui.code-workspace rename src/Ombi.Core/Rule/Rules/Specific/{CanRequestRule.cs => SendNotificationRule.cs} (58%) diff --git a/appveyor.yml b/appveyor.yml index a72406a0c..d8f43711b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,6 +9,8 @@ install: - ps: Install-Product node $env:nodejs_version build_script: - ps: ./build.ps1 --settings_skipverification=true + +test: off after_build: - cmd: >- diff --git a/src/.vscode/src.code-workspace b/src/.vscode/src.code-workspace new file mode 100644 index 000000000..64b1e372e --- /dev/null +++ b/src/.vscode/src.code-workspace @@ -0,0 +1,13 @@ +{ + "folders": [ + { + "path": "C:\\Users\\Jamie.Rees\\Source\\Repos\\test2\\ombi\\src" + } + ], + "settings": { + "files.associations": { + "dockerfile.*": "dockerfile" + }, + "typescript.tsdk": "node_modules\\typescript\\lib" + } +} \ No newline at end of file diff --git a/src/.vscode/ui.code-workspace b/src/.vscode/ui.code-workspace new file mode 100644 index 000000000..77395a545 --- /dev/null +++ b/src/.vscode/ui.code-workspace @@ -0,0 +1,10 @@ +{ + "folders": [ + { + "path": "C:\\Users\\Jamie.Rees\\Source\\Repos\\test2\\ombi\\src\\Ombi" + } + ], + "settings": { + "typescript.tsdk": "node_modules\\typescript\\lib" + } +} \ No newline at end of file diff --git a/src/Ombi.Core/Rule/Rules/Specific/CanRequestRule.cs b/src/Ombi.Core/Rule/Rules/Specific/SendNotificationRule.cs similarity index 58% rename from src/Ombi.Core/Rule/Rules/Specific/CanRequestRule.cs rename to src/Ombi.Core/Rule/Rules/Specific/SendNotificationRule.cs index bf7275169..50ac607cb 100644 --- a/src/Ombi.Core/Rule/Rules/Specific/CanRequestRule.cs +++ b/src/Ombi.Core/Rule/Rules/Specific/SendNotificationRule.cs @@ -2,7 +2,9 @@ using Microsoft.EntityFrameworkCore; using Ombi.Core.Authentication; using Ombi.Core.Rule.Interfaces; +using Ombi.Core.Settings; using Ombi.Helpers; +using Ombi.Settings.Settings.Models; using Ombi.Store.Entities; using Ombi.Store.Entities.Requests; @@ -10,33 +12,42 @@ namespace Ombi.Core.Rule.Rules.Specific { public class SendNotificationRule : SpecificRule, ISpecificRule { - public SendNotificationRule(OmbiUserManager um) + public SendNotificationRule(OmbiUserManager um, ISettingsService settings) { UserManager = um; + Settings = settings; } public override SpecificRules Rule => SpecificRules.CanSendNotification; private OmbiUserManager UserManager { get; } + private ISettingsService Settings { get; } public async Task Execute(object obj) { var req = (BaseRequest)obj; - var sendNotification = !req.Approved; /*|| !prSettings.IgnoreNotifyForAutoApprovedRequests;*/ + var settings = await Settings.GetSettingsAsync(); + var sendNotification = true; var requestedUser = await UserManager.Users.FirstOrDefaultAsync(x => x.Id == req.RequestedUserId); if (req.RequestType == RequestType.Movie) { - sendNotification = !await UserManager.IsInRoleAsync(requestedUser, OmbiRoles.AutoApproveMovie); + if (settings.DoNotSendNotificationsForAutoApprove) + { + sendNotification = !await UserManager.IsInRoleAsync(requestedUser, OmbiRoles.AutoApproveMovie); + } } - else if(req.RequestType == RequestType.TvShow) + else if (req.RequestType == RequestType.TvShow) { - sendNotification = !await UserManager.IsInRoleAsync(requestedUser, OmbiRoles.AutoApproveTv); + if (settings.DoNotSendNotificationsForAutoApprove) + { + sendNotification = !await UserManager.IsInRoleAsync(requestedUser, OmbiRoles.AutoApproveTv); + } } if (await UserManager.IsInRoleAsync(requestedUser, OmbiRoles.Admin)) { sendNotification = false; // Don't bother sending a notification if the user is an admin } - + return new RuleResult { diff --git a/src/Ombi.Settings/Settings/Models/OmbiSettings.cs b/src/Ombi.Settings/Settings/Models/OmbiSettings.cs index c4bf18ad1..ee9d5943b 100644 --- a/src/Ombi.Settings/Settings/Models/OmbiSettings.cs +++ b/src/Ombi.Settings/Settings/Models/OmbiSettings.cs @@ -7,6 +7,7 @@ public bool Wizard { get; set; } public string ApiKey { get; set; } public bool IgnoreCertificateErrors { get; set; } + public bool DoNotSendNotificationsForAutoApprove {get;set;} } } \ No newline at end of file diff --git a/src/Ombi/ClientApp/app/interfaces/ISettings.ts b/src/Ombi/ClientApp/app/interfaces/ISettings.ts index 4f3058f4e..83b2b70f3 100644 --- a/src/Ombi/ClientApp/app/interfaces/ISettings.ts +++ b/src/Ombi/ClientApp/app/interfaces/ISettings.ts @@ -13,6 +13,7 @@ export interface IOmbiSettings extends ISettings { wizard: boolean; apiKey: string; ignoreCertificateErrors: boolean; + doNotSendNotificationsForAutoApprove: boolean; } export interface IUpdateSettings extends ISettings { diff --git a/src/Ombi/ClientApp/app/settings/ombi/ombi.component.html b/src/Ombi/ClientApp/app/settings/ombi/ombi.component.html index 0d416c3d7..c7a7025de 100644 --- a/src/Ombi/ClientApp/app/settings/ombi/ombi.component.html +++ b/src/Ombi/ClientApp/app/settings/ombi/ombi.component.html @@ -45,6 +45,14 @@
+ +
+
+ + +
+
+
diff --git a/src/Ombi/ClientApp/app/settings/ombi/ombi.component.ts b/src/Ombi/ClientApp/app/settings/ombi/ombi.component.ts index 59a81ab71..dbdb75d23 100644 --- a/src/Ombi/ClientApp/app/settings/ombi/ombi.component.ts +++ b/src/Ombi/ClientApp/app/settings/ombi/ombi.component.ts @@ -22,6 +22,7 @@ export class OmbiComponent implements OnInit { apiKey: [x.apiKey], ignoreCertificateErrors: [x.ignoreCertificateErrors], baseUrl: [x.baseUrl], + doNotSendNotificationsForAutoApprove: [x.doNotSendNotificationsForAutoApprove], }); }); }