mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-14 17:22:54 -07:00
Added the ability to hide requests that have not been made by that user (#2052)
This commit is contained in:
parent
28080fd8ab
commit
152818f8d1
21 changed files with 284 additions and 52 deletions
|
@ -14,6 +14,8 @@ using Ombi.Store.Repository.Requests;
|
|||
using Ombi.Store.Entities;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Ombi.Core.Authentication;
|
||||
using Ombi.Core.Settings;
|
||||
using Ombi.Settings.Settings.Models;
|
||||
|
||||
namespace Ombi.Core.Engine
|
||||
{
|
||||
|
@ -24,14 +26,18 @@ namespace Ombi.Core.Engine
|
|||
private Dictionary<int, TvRequests> _dbTv;
|
||||
|
||||
protected BaseMediaEngine(IPrincipal identity, IRequestServiceMain requestService,
|
||||
IRuleEvaluator rules, OmbiUserManager um) : base(identity, um, rules)
|
||||
IRuleEvaluator rules, OmbiUserManager um, ICacheService cache, ISettingsService<OmbiSettings> ombiSettings) : base(identity, um, rules)
|
||||
{
|
||||
RequestService = requestService;
|
||||
Cache = cache;
|
||||
OmbiSettings = ombiSettings;
|
||||
}
|
||||
|
||||
protected IRequestServiceMain RequestService { get; }
|
||||
protected IMovieRequestRepository MovieRepository => RequestService.MovieRequestService;
|
||||
protected ITvRequestRepository TvRepository => RequestService.TvRequestService;
|
||||
protected readonly ICacheService Cache;
|
||||
protected readonly ISettingsService<OmbiSettings> OmbiSettings;
|
||||
|
||||
protected async Task<Dictionary<int, MovieRequests>> GetMovieRequests()
|
||||
{
|
||||
|
@ -99,5 +105,30 @@ namespace Ombi.Core.Engine
|
|||
Pending = pendingMovies + pendingTv
|
||||
};
|
||||
}
|
||||
|
||||
protected async Task<HideResult> HideFromOtherUsers()
|
||||
{
|
||||
if (await IsInRole(OmbiRoles.Admin) || await IsInRole(OmbiRoles.PowerUser))
|
||||
{
|
||||
return new HideResult();
|
||||
}
|
||||
var settings = await Cache.GetOrAdd(CacheKeys.OmbiSettings, async () => await OmbiSettings.GetSettingsAsync());
|
||||
var result = new HideResult
|
||||
{
|
||||
Hide = settings.HideRequestsUsers
|
||||
};
|
||||
if (settings.HideRequestsUsers)
|
||||
{
|
||||
var user = await GetUser();
|
||||
result.UserId = user.Id;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public class HideResult
|
||||
{
|
||||
public bool Hide { get; set; }
|
||||
public string UserId { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue