mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
* feat: updated radarr settings API to support 4k * feat: refactored the radarr setting page to support the new model * feat: Added 4k radarr to the settings page * feat: Added the new Movie 4k Request * feat: Got some of the backend rules done * feat: Made a load of progress * Removed the csproj ref * feat: fixed the radarr ui * feat: fixed up all the movie requests page * feat: Hide the 4K buttons when the user does not have the 4k permission * fix: fixed the templateref issue * test: fixed up all the tests * feat: Added migrations for media sever quality. Emby and Radarr Sync jobs now pull the quality * feat: Done the media sync jobs * feat: plex availability checker * feat: Updated the jellyfin availability checker to check for 4k * feat: updated emby availbility checker to check for 4k * feat: almost got it all working now * feat: Added 4k approve to the request list options * feat: Added 4k to the requests list and bulk approve * feat: Added the features service * feat: added feature update to the frontend * feat: got the features page working * feat: Applied the feature service on the backend * feat: added the feature flag on the UI * feat: added 4k to the card
79 lines
2.9 KiB
C#
79 lines
2.9 KiB
C#
using System;
|
|
using Ombi.Store.Entities;
|
|
using System.IO;
|
|
using System.Security.Claims;
|
|
using System.Security.Principal;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Ombi.Core.Authentication;
|
|
using Ombi.Core.Engine;
|
|
using Ombi.Core.Rule.Interfaces;
|
|
using Ombi.Helpers;
|
|
using Ombi.Store.Entities.Requests;
|
|
|
|
namespace Ombi.Core.Rule.Rules.Request
|
|
{
|
|
public class CanRequestRule : BaseRequestRule, IRules<BaseRequest>
|
|
{
|
|
public CanRequestRule(IPrincipal principal, OmbiUserManager manager)
|
|
{
|
|
User = principal;
|
|
_manager = manager;
|
|
}
|
|
|
|
private IPrincipal User { get; }
|
|
private readonly OmbiUserManager _manager;
|
|
|
|
public async Task<RuleResult> Execute(BaseRequest obj)
|
|
{
|
|
var username = User.Identity.Name.ToUpper();
|
|
var user = await _manager.Users.FirstOrDefaultAsync(x => x.NormalizedUserName == username);
|
|
if (await _manager.IsInRoleAsync(user, OmbiRoles.Admin) || user.IsSystemUser)
|
|
return Success();
|
|
|
|
if (obj.RequestType == RequestType.Movie)
|
|
{
|
|
var movie = (MovieRequests)obj;
|
|
var hasAutoApprove = await _manager.IsInRoleAsync(user, OmbiRoles.AutoApproveMovie);
|
|
if (await _manager.IsInRoleAsync(user, OmbiRoles.RequestMovie) || hasAutoApprove)
|
|
{
|
|
if (movie.Is4kRequest && !hasAutoApprove)
|
|
{
|
|
var has4kPermission = await _manager.IsInRoleAsync(user, OmbiRoles.Request4KMovie);
|
|
if (has4kPermission)
|
|
{
|
|
return Success();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return Success();
|
|
}
|
|
}
|
|
return Fail(ErrorCode.NoPermissionsRequestMovie, "You do not have permissions to Request a Movie");
|
|
}
|
|
|
|
if (obj.RequestType == RequestType.TvShow)
|
|
{
|
|
if (await _manager.IsInRoleAsync(user, OmbiRoles.RequestTv) || await _manager.IsInRoleAsync(user, OmbiRoles.AutoApproveTv))
|
|
{
|
|
return Success();
|
|
}
|
|
|
|
return Fail(ErrorCode.NoPermissionsRequestTV, "You do not have permissions to Request a TV Show");
|
|
}
|
|
|
|
if (obj.RequestType == RequestType.Album)
|
|
{
|
|
if (await _manager.IsInRoleAsync(user, OmbiRoles.RequestMusic) || await _manager.IsInRoleAsync(user, OmbiRoles.AutoApproveMusic))
|
|
{
|
|
return Success();
|
|
}
|
|
|
|
return Fail(ErrorCode.NoPermissionsRequestAlbum, "You do not have permissions to Request an Album");
|
|
}
|
|
|
|
throw new InvalidDataException("Permission check failed: unknown RequestType");
|
|
}
|
|
}
|
|
}
|