mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-31 03:50:08 -07:00
#1659 Made the option to ignore notifcations for auto approve
This commit is contained in:
parent
183f3593df
commit
8d5dfe9424
8 changed files with 53 additions and 6 deletions
|
@ -10,6 +10,8 @@ install:
|
||||||
build_script:
|
build_script:
|
||||||
- ps: ./build.ps1 --settings_skipverification=true
|
- ps: ./build.ps1 --settings_skipverification=true
|
||||||
|
|
||||||
|
test: off
|
||||||
|
|
||||||
after_build:
|
after_build:
|
||||||
- cmd: >-
|
- cmd: >-
|
||||||
|
|
||||||
|
|
13
src/.vscode/src.code-workspace
vendored
Normal file
13
src/.vscode/src.code-workspace
vendored
Normal file
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
10
src/.vscode/ui.code-workspace
vendored
Normal file
10
src/.vscode/ui.code-workspace
vendored
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"folders": [
|
||||||
|
{
|
||||||
|
"path": "C:\\Users\\Jamie.Rees\\Source\\Repos\\test2\\ombi\\src\\Ombi"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"settings": {
|
||||||
|
"typescript.tsdk": "node_modules\\typescript\\lib"
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,9 @@
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Ombi.Core.Authentication;
|
using Ombi.Core.Authentication;
|
||||||
using Ombi.Core.Rule.Interfaces;
|
using Ombi.Core.Rule.Interfaces;
|
||||||
|
using Ombi.Core.Settings;
|
||||||
using Ombi.Helpers;
|
using Ombi.Helpers;
|
||||||
|
using Ombi.Settings.Settings.Models;
|
||||||
using Ombi.Store.Entities;
|
using Ombi.Store.Entities;
|
||||||
using Ombi.Store.Entities.Requests;
|
using Ombi.Store.Entities.Requests;
|
||||||
|
|
||||||
|
@ -10,27 +12,36 @@ namespace Ombi.Core.Rule.Rules.Specific
|
||||||
{
|
{
|
||||||
public class SendNotificationRule : SpecificRule, ISpecificRule<object>
|
public class SendNotificationRule : SpecificRule, ISpecificRule<object>
|
||||||
{
|
{
|
||||||
public SendNotificationRule(OmbiUserManager um)
|
public SendNotificationRule(OmbiUserManager um, ISettingsService<OmbiSettings> settings)
|
||||||
{
|
{
|
||||||
UserManager = um;
|
UserManager = um;
|
||||||
|
Settings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SpecificRules Rule => SpecificRules.CanSendNotification;
|
public override SpecificRules Rule => SpecificRules.CanSendNotification;
|
||||||
private OmbiUserManager UserManager { get; }
|
private OmbiUserManager UserManager { get; }
|
||||||
|
private ISettingsService<OmbiSettings> Settings { get; }
|
||||||
|
|
||||||
public async Task<RuleResult> Execute(object obj)
|
public async Task<RuleResult> Execute(object obj)
|
||||||
{
|
{
|
||||||
var req = (BaseRequest)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);
|
var requestedUser = await UserManager.Users.FirstOrDefaultAsync(x => x.Id == req.RequestedUserId);
|
||||||
if (req.RequestType == RequestType.Movie)
|
if (req.RequestType == RequestType.Movie)
|
||||||
|
{
|
||||||
|
if (settings.DoNotSendNotificationsForAutoApprove)
|
||||||
{
|
{
|
||||||
sendNotification = !await UserManager.IsInRoleAsync(requestedUser, OmbiRoles.AutoApproveMovie);
|
sendNotification = !await UserManager.IsInRoleAsync(requestedUser, OmbiRoles.AutoApproveMovie);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (req.RequestType == RequestType.TvShow)
|
else if (req.RequestType == RequestType.TvShow)
|
||||||
|
{
|
||||||
|
if (settings.DoNotSendNotificationsForAutoApprove)
|
||||||
{
|
{
|
||||||
sendNotification = !await UserManager.IsInRoleAsync(requestedUser, OmbiRoles.AutoApproveTv);
|
sendNotification = !await UserManager.IsInRoleAsync(requestedUser, OmbiRoles.AutoApproveTv);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (await UserManager.IsInRoleAsync(requestedUser, OmbiRoles.Admin))
|
if (await UserManager.IsInRoleAsync(requestedUser, OmbiRoles.Admin))
|
||||||
{
|
{
|
|
@ -7,6 +7,7 @@
|
||||||
public bool Wizard { get; set; }
|
public bool Wizard { get; set; }
|
||||||
public string ApiKey { get; set; }
|
public string ApiKey { get; set; }
|
||||||
public bool IgnoreCertificateErrors { get; set; }
|
public bool IgnoreCertificateErrors { get; set; }
|
||||||
|
public bool DoNotSendNotificationsForAutoApprove {get;set;}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -13,6 +13,7 @@ export interface IOmbiSettings extends ISettings {
|
||||||
wizard: boolean;
|
wizard: boolean;
|
||||||
apiKey: string;
|
apiKey: string;
|
||||||
ignoreCertificateErrors: boolean;
|
ignoreCertificateErrors: boolean;
|
||||||
|
doNotSendNotificationsForAutoApprove: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IUpdateSettings extends ISettings {
|
export interface IUpdateSettings extends ISettings {
|
||||||
|
|
|
@ -45,6 +45,14 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="checkbox">
|
||||||
|
<input type="checkbox" id="doNotSendNotificationsForAutoApprove" name="doNotSendNotificationsForAutoApprove" formControlName="doNotSendNotificationsForAutoApprove">
|
||||||
|
<label for="doNotSendNotificationsForAutoApprove">Do not send Notifications if a User has the Auto Approve permission</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<input type="checkbox" id="ignoreCertificateErrors" name="ignoreCertificateErrors" formControlName="ignoreCertificateErrors">
|
<input type="checkbox" id="ignoreCertificateErrors" name="ignoreCertificateErrors" formControlName="ignoreCertificateErrors">
|
||||||
|
|
|
@ -22,6 +22,7 @@ export class OmbiComponent implements OnInit {
|
||||||
apiKey: [x.apiKey],
|
apiKey: [x.apiKey],
|
||||||
ignoreCertificateErrors: [x.ignoreCertificateErrors],
|
ignoreCertificateErrors: [x.ignoreCertificateErrors],
|
||||||
baseUrl: [x.baseUrl],
|
baseUrl: [x.baseUrl],
|
||||||
|
doNotSendNotificationsForAutoApprove: [x.doNotSendNotificationsForAutoApprove],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue