mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-30 19:40:05 -07:00
Fixed #1760 and improvements on the auto updater.
We may now support windows services... #1460
This commit is contained in:
parent
3edb4a485a
commit
02135bc550
15 changed files with 170 additions and 91 deletions
10
src/Ombi.Core/Models/UI/UpdateSettingsViewModel.cs
Normal file
10
src/Ombi.Core/Models/UI/UpdateSettingsViewModel.cs
Normal file
|
@ -0,0 +1,10 @@
|
|||
using System.Runtime.InteropServices;
|
||||
using Ombi.Settings.Settings.Models;
|
||||
|
||||
namespace Ombi.Core.Models.UI
|
||||
{
|
||||
public class UpdateSettingsViewModel : UpdateSettings
|
||||
{
|
||||
public bool IsWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
using System.Security.Principal;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Ombi.Core.Authentication;
|
||||
using Ombi.Core.Rule.Interfaces;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Store.Entities;
|
||||
|
@ -9,40 +10,38 @@ namespace Ombi.Core.Rule.Rules.Specific
|
|||
{
|
||||
public class SendNotificationRule : SpecificRule, ISpecificRule<object>
|
||||
{
|
||||
public SendNotificationRule(IPrincipal principal)
|
||||
public SendNotificationRule(OmbiUserManager um)
|
||||
{
|
||||
User = principal;
|
||||
UserManager = um;
|
||||
}
|
||||
|
||||
public override SpecificRules Rule => SpecificRules.CanSendNotification;
|
||||
private IPrincipal User { get; }
|
||||
private OmbiUserManager UserManager { get; }
|
||||
|
||||
public Task<RuleResult> Execute(object obj)
|
||||
public async Task<RuleResult> Execute(object obj)
|
||||
{
|
||||
var req = (BaseRequest)obj;
|
||||
var sendNotification = !req.Approved; /*|| !prSettings.IgnoreNotifyForAutoApprovedRequests;*/
|
||||
|
||||
var requestedUser = await UserManager.Users.FirstOrDefaultAsync(x => x.Id == req.RequestedUserId);
|
||||
if (req.RequestType == RequestType.Movie)
|
||||
{
|
||||
sendNotification = !User.IsInRole(OmbiRoles.AutoApproveMovie);
|
||||
sendNotification = !await UserManager.IsInRoleAsync(requestedUser, OmbiRoles.AutoApproveMovie);
|
||||
}
|
||||
else if(req.RequestType == RequestType.TvShow)
|
||||
{
|
||||
sendNotification = !User.IsInRole(OmbiRoles.AutoApproveTv);
|
||||
sendNotification = !await UserManager.IsInRoleAsync(requestedUser, OmbiRoles.AutoApproveTv);
|
||||
}
|
||||
|
||||
|
||||
if (User.IsInRole(OmbiRoles.Admin))
|
||||
if (await UserManager.IsInRoleAsync(requestedUser, OmbiRoles.Admin))
|
||||
{
|
||||
sendNotification = false; // Don't bother sending a notification if the user is an admin
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return Task.FromResult(new RuleResult
|
||||
return new RuleResult
|
||||
{
|
||||
Success = sendNotification
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue