mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-12 16:22:55 -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,7 @@ ___
|
|||
|
||||
[](https://forums.ombi.io/viewforum.php?f=10) [](https://forums.ombi.io/posting.php?mode=post&f=20)
|
||||
|
||||
|
||||
| Service | Stable | Develop |
|
||||
|----------|:---------------------------:|:----------------------------:|
|
||||
| AppVeyor | [](https://ci.appveyor.com/project/tidusjar/requestplex/branch/master) | [](https://ci.appveyor.com/project/tidusjar/requestplex/branch/develop) |
|
||||
|
|
|
@ -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; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,6 +17,6 @@ namespace Ombi.Core.Engine.Interfaces
|
|||
Task<RequestEngineResult> ApproveMovie(MovieRequests request);
|
||||
Task<RequestEngineResult> ApproveMovieById(int requestId);
|
||||
Task<RequestEngineResult> DenyMovieById(int modelId);
|
||||
IEnumerable<MovieRequests> Filter(FilterViewModel vm);
|
||||
Task<IEnumerable<MovieRequests>> Filter(FilterViewModel vm);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
using Ombi.Api.TheMovieDb;
|
||||
using Ombi.Core.Models.Requests;
|
||||
using Ombi.Core.Models.Search;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Store.Entities;
|
||||
using System;
|
||||
|
@ -15,6 +14,8 @@ using Ombi.Api.TheMovieDb.Models;
|
|||
using Ombi.Core.Authentication;
|
||||
using Ombi.Core.Engine.Interfaces;
|
||||
using Ombi.Core.Rule.Interfaces;
|
||||
using Ombi.Core.Settings;
|
||||
using Ombi.Settings.Settings.Models;
|
||||
using Ombi.Store.Entities.Requests;
|
||||
using Ombi.Store.Repository;
|
||||
|
||||
|
@ -24,7 +25,7 @@ namespace Ombi.Core.Engine
|
|||
{
|
||||
public MovieRequestEngine(IMovieDbApi movieApi, IRequestServiceMain requestService, IPrincipal user,
|
||||
INotificationHelper helper, IRuleEvaluator r, IMovieSender sender, ILogger<MovieRequestEngine> log,
|
||||
OmbiUserManager manager, IRepository<RequestLog> rl) : base(user, requestService, r, manager)
|
||||
OmbiUserManager manager, IRepository<RequestLog> rl, ICacheService cache, ISettingsService<OmbiSettings> ombiSettings) : base(user, requestService, r, manager, cache, ombiSettings)
|
||||
{
|
||||
MovieApi = movieApi;
|
||||
NotificationHelper = helper;
|
||||
|
@ -126,7 +127,16 @@ namespace Ombi.Core.Engine
|
|||
/// <returns></returns>
|
||||
public async Task<IEnumerable<MovieRequests>> GetRequests(int count, int position)
|
||||
{
|
||||
var allRequests = await MovieRepository.GetWithUser().Skip(position).Take(count).ToListAsync();
|
||||
var shouldHide = await HideFromOtherUsers();
|
||||
List<MovieRequests> allRequests;
|
||||
if (shouldHide.Hide)
|
||||
{
|
||||
allRequests = await MovieRepository.GetWithUser(shouldHide.UserId).Skip(position).Take(count).ToListAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
allRequests = await MovieRepository.GetWithUser().Skip(position).Take(count).ToListAsync();
|
||||
}
|
||||
allRequests.ForEach(x =>
|
||||
{
|
||||
x.PosterPath = PosterPathHelper.FixPosterPath(x.PosterPath);
|
||||
|
@ -140,7 +150,16 @@ namespace Ombi.Core.Engine
|
|||
/// <returns></returns>
|
||||
public async Task<IEnumerable<MovieRequests>> GetRequests()
|
||||
{
|
||||
var allRequests = await MovieRepository.GetWithUser().ToListAsync();
|
||||
var shouldHide = await HideFromOtherUsers();
|
||||
List<MovieRequests> allRequests;
|
||||
if (shouldHide.Hide)
|
||||
{
|
||||
allRequests = await MovieRepository.GetWithUser(shouldHide.UserId).ToListAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
allRequests = await MovieRepository.GetWithUser().ToListAsync();
|
||||
}
|
||||
return allRequests;
|
||||
}
|
||||
|
||||
|
@ -151,7 +170,16 @@ namespace Ombi.Core.Engine
|
|||
/// <returns></returns>
|
||||
public async Task<IEnumerable<MovieRequests>> SearchMovieRequest(string search)
|
||||
{
|
||||
var allRequests = await MovieRepository.GetWithUser().ToListAsync();
|
||||
var shouldHide = await HideFromOtherUsers();
|
||||
List<MovieRequests> allRequests;
|
||||
if (shouldHide.Hide)
|
||||
{
|
||||
allRequests = await MovieRepository.GetWithUser(shouldHide.UserId).ToListAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
allRequests = await MovieRepository.GetWithUser().ToListAsync();
|
||||
}
|
||||
var results = allRequests.Where(x => x.Title.Contains(search, CompareOptions.IgnoreCase)).ToList();
|
||||
results.ForEach(x =>
|
||||
{
|
||||
|
@ -339,9 +367,10 @@ namespace Ombi.Core.Engine
|
|||
return new RequestEngineResult { Result = true, Message = $"{movieName} has been successfully added!" };
|
||||
}
|
||||
|
||||
public IEnumerable<MovieRequests> Filter(FilterViewModel vm)
|
||||
public async Task<IEnumerable<MovieRequests>> Filter(FilterViewModel vm)
|
||||
{
|
||||
var requests = MovieRepository.GetWithUser();
|
||||
var shouldHide = await HideFromOtherUsers();
|
||||
var requests = shouldHide.Hide ? MovieRepository.GetWithUser(shouldHide.UserId) : MovieRepository.GetWithUser();
|
||||
switch (vm.AvailabilityFilter)
|
||||
{
|
||||
case FilterType.None:
|
||||
|
|
|
@ -12,26 +12,26 @@ using System.Threading.Tasks;
|
|||
using Ombi.Core.Rule.Interfaces;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Ombi.Core.Authentication;
|
||||
using Ombi.Core.Settings;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Settings.Settings.Models;
|
||||
|
||||
namespace Ombi.Core.Engine
|
||||
{
|
||||
public class MovieSearchEngine : BaseMediaEngine, IMovieEngine
|
||||
{
|
||||
public MovieSearchEngine(IPrincipal identity, IRequestServiceMain service, IMovieDbApi movApi, IMapper mapper,
|
||||
ILogger<MovieSearchEngine> logger, IRuleEvaluator r, OmbiUserManager um, ICacheService mem)
|
||||
: base(identity, service, r, um)
|
||||
ILogger<MovieSearchEngine> logger, IRuleEvaluator r, OmbiUserManager um, ICacheService mem, ISettingsService<OmbiSettings> s)
|
||||
: base(identity, service, r, um, mem, s)
|
||||
{
|
||||
MovieApi = movApi;
|
||||
Mapper = mapper;
|
||||
Logger = logger;
|
||||
MemCache = mem;
|
||||
}
|
||||
|
||||
private IMovieDbApi MovieApi { get; }
|
||||
private IMapper Mapper { get; }
|
||||
private ILogger<MovieSearchEngine> Logger { get; }
|
||||
private ICacheService MemCache { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Lookups the imdb information.
|
||||
|
@ -85,7 +85,7 @@ namespace Ombi.Core.Engine
|
|||
/// <returns></returns>
|
||||
public async Task<IEnumerable<SearchMovieViewModel>> PopularMovies()
|
||||
{
|
||||
var result = await MemCache.GetOrAdd(CacheKeys.PopularMovies, async () => await MovieApi.PopularMovies(), DateTime.Now.AddHours(12));
|
||||
var result = await Cache.GetOrAdd(CacheKeys.PopularMovies, async () => await MovieApi.PopularMovies(), DateTime.Now.AddHours(12));
|
||||
if (result != null)
|
||||
{
|
||||
Logger.LogDebug("Search Result: {result}", result);
|
||||
|
@ -100,7 +100,7 @@ namespace Ombi.Core.Engine
|
|||
/// <returns></returns>
|
||||
public async Task<IEnumerable<SearchMovieViewModel>> TopRatedMovies()
|
||||
{
|
||||
var result = await MemCache.GetOrAdd(CacheKeys.TopRatedMovies, async () => await MovieApi.TopRated(), DateTime.Now.AddHours(12));
|
||||
var result = await Cache.GetOrAdd(CacheKeys.TopRatedMovies, async () => await MovieApi.TopRated(), DateTime.Now.AddHours(12));
|
||||
if (result != null)
|
||||
{
|
||||
Logger.LogDebug("Search Result: {result}", result);
|
||||
|
@ -115,7 +115,7 @@ namespace Ombi.Core.Engine
|
|||
/// <returns></returns>
|
||||
public async Task<IEnumerable<SearchMovieViewModel>> UpcomingMovies()
|
||||
{
|
||||
var result = await MemCache.GetOrAdd(CacheKeys.UpcomingMovies, async () => await MovieApi.Upcoming(), DateTime.Now.AddHours(12));
|
||||
var result = await Cache.GetOrAdd(CacheKeys.UpcomingMovies, async () => await MovieApi.Upcoming(), DateTime.Now.AddHours(12));
|
||||
if (result != null)
|
||||
{
|
||||
Logger.LogDebug("Search Result: {result}", result);
|
||||
|
@ -130,7 +130,7 @@ namespace Ombi.Core.Engine
|
|||
/// <returns></returns>
|
||||
public async Task<IEnumerable<SearchMovieViewModel>> NowPlayingMovies()
|
||||
{
|
||||
var result = await MemCache.GetOrAdd(CacheKeys.NowPlayingMovies, async () => await MovieApi.NowPlaying(), DateTime.Now.AddHours(12));
|
||||
var result = await Cache.GetOrAdd(CacheKeys.NowPlayingMovies, async () => await MovieApi.NowPlaying(), DateTime.Now.AddHours(12));
|
||||
if (result != null)
|
||||
{
|
||||
Logger.LogDebug("Search Result: {result}", result);
|
||||
|
|
|
@ -17,6 +17,8 @@ using Ombi.Core.Helpers;
|
|||
using Ombi.Core.Rule;
|
||||
using Ombi.Core.Rule.Interfaces;
|
||||
using Ombi.Core.Senders;
|
||||
using Ombi.Core.Settings;
|
||||
using Ombi.Settings.Settings.Models;
|
||||
using Ombi.Store.Entities.Requests;
|
||||
using Ombi.Store.Repository;
|
||||
|
||||
|
@ -26,7 +28,7 @@ namespace Ombi.Core.Engine
|
|||
{
|
||||
public TvRequestEngine(ITvMazeApi tvApi, IRequestServiceMain requestService, IPrincipal user,
|
||||
INotificationHelper helper, IRuleEvaluator rule, OmbiUserManager manager,
|
||||
ITvSender sender, IAuditRepository audit, IRepository<RequestLog> rl) : base(user, requestService, rule, manager)
|
||||
ITvSender sender, IAuditRepository audit, IRepository<RequestLog> rl, ISettingsService<OmbiSettings> settings, ICacheService cache) : base(user, requestService, rule, manager, cache, settings)
|
||||
{
|
||||
TvApi = tvApi;
|
||||
NotificationHelper = helper;
|
||||
|
@ -128,45 +130,136 @@ namespace Ombi.Core.Engine
|
|||
|
||||
public async Task<IEnumerable<TvRequests>> GetRequests(int count, int position)
|
||||
{
|
||||
var allRequests = await TvRepository.Get()
|
||||
var shouldHide = await HideFromOtherUsers();
|
||||
List<TvRequests> allRequests;
|
||||
if (shouldHide.Hide)
|
||||
{
|
||||
allRequests = await TvRepository.Get(shouldHide.UserId)
|
||||
.Include(x => x.ChildRequests)
|
||||
.ThenInclude(x => x.SeasonRequests)
|
||||
.ThenInclude(x => x.Episodes)
|
||||
.Skip(position).Take(count).ToListAsync();
|
||||
|
||||
// Filter out children
|
||||
|
||||
FilterChildren(allRequests, shouldHide);
|
||||
}
|
||||
else
|
||||
{
|
||||
allRequests = await TvRepository.Get()
|
||||
.Include(x => x.ChildRequests)
|
||||
.ThenInclude(x => x.SeasonRequests)
|
||||
.ThenInclude(x => x.Episodes)
|
||||
.Skip(position).Take(count).ToListAsync();
|
||||
}
|
||||
|
||||
return allRequests;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<TreeNode<TvRequests, List<ChildRequests>>>> GetRequestsTreeNode(int count, int position)
|
||||
{
|
||||
var allRequests = await TvRepository.Get()
|
||||
var shouldHide = await HideFromOtherUsers();
|
||||
List<TvRequests> allRequests;
|
||||
if (shouldHide.Hide)
|
||||
{
|
||||
allRequests = await TvRepository.Get(shouldHide.UserId)
|
||||
.Include(x => x.ChildRequests)
|
||||
.ThenInclude(x => x.SeasonRequests)
|
||||
.ThenInclude(x => x.Episodes)
|
||||
.Skip(position).Take(count).ToListAsync();
|
||||
|
||||
FilterChildren(allRequests, shouldHide);
|
||||
}
|
||||
else
|
||||
{
|
||||
allRequests = await TvRepository.Get()
|
||||
.Include(x => x.ChildRequests)
|
||||
.ThenInclude(x => x.SeasonRequests)
|
||||
.ThenInclude(x => x.Episodes)
|
||||
.Skip(position).Take(count).ToListAsync();
|
||||
}
|
||||
return ParseIntoTreeNode(allRequests);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<TvRequests>> GetRequests()
|
||||
{
|
||||
var allRequests = TvRepository.Get();
|
||||
var shouldHide = await HideFromOtherUsers();
|
||||
IQueryable<TvRequests> allRequests;
|
||||
if (shouldHide.Hide)
|
||||
{
|
||||
allRequests = TvRepository.Get(shouldHide.UserId);
|
||||
|
||||
FilterChildren(allRequests, shouldHide);
|
||||
}
|
||||
else
|
||||
{
|
||||
allRequests = TvRepository.Get();
|
||||
}
|
||||
|
||||
return await allRequests.ToListAsync();
|
||||
}
|
||||
|
||||
private static void FilterChildren(IEnumerable<TvRequests> allRequests, HideResult shouldHide)
|
||||
{
|
||||
// Filter out children
|
||||
foreach (var t in allRequests)
|
||||
{
|
||||
for (var j = 0; j < t.ChildRequests.Count; j++)
|
||||
{
|
||||
var child = t.ChildRequests[j];
|
||||
if (child.RequestedUserId != shouldHide.UserId)
|
||||
{
|
||||
t.ChildRequests.RemoveAt(j);
|
||||
j--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ChildRequests>> GetAllChldren(int tvId)
|
||||
{
|
||||
return await TvRepository.GetChild().Include(x => x.SeasonRequests).Where(x => x.ParentRequestId == tvId).ToListAsync();
|
||||
var shouldHide = await HideFromOtherUsers();
|
||||
List<ChildRequests> allRequests;
|
||||
if (shouldHide.Hide)
|
||||
{
|
||||
allRequests = await TvRepository.GetChild(shouldHide.UserId).Include(x => x.SeasonRequests).Where(x => x.ParentRequestId == tvId).ToListAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
allRequests = await TvRepository.GetChild().Include(x => x.SeasonRequests).Where(x => x.ParentRequestId == tvId).ToListAsync();
|
||||
}
|
||||
|
||||
return allRequests;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<TvRequests>> SearchTvRequest(string search)
|
||||
{
|
||||
var allRequests = TvRepository.Get();
|
||||
var shouldHide = await HideFromOtherUsers();
|
||||
IQueryable<TvRequests> allRequests;
|
||||
if (shouldHide.Hide)
|
||||
{
|
||||
allRequests = TvRepository.Get(shouldHide.UserId);
|
||||
}
|
||||
else
|
||||
{
|
||||
allRequests = TvRepository.Get();
|
||||
}
|
||||
var results = await allRequests.Where(x => x.Title.Contains(search, CompareOptions.IgnoreCase)).ToListAsync();
|
||||
return results;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<TreeNode<TvRequests, List<ChildRequests>>>> SearchTvRequestTree(string search)
|
||||
{
|
||||
var allRequests = TvRepository.Get();
|
||||
var shouldHide = await HideFromOtherUsers();
|
||||
IQueryable<TvRequests> allRequests;
|
||||
if (shouldHide.Hide)
|
||||
{
|
||||
allRequests = TvRepository.Get(shouldHide.UserId);
|
||||
}
|
||||
else
|
||||
{
|
||||
allRequests = TvRepository.Get();
|
||||
}
|
||||
var results = await allRequests.Where(x => x.Title.Contains(search, CompareOptions.IgnoreCase)).ToListAsync();
|
||||
return ParseIntoTreeNode(results);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ using Ombi.Store.Repository.Requests;
|
|||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Ombi.Core.Authentication;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Settings.Settings.Models;
|
||||
|
||||
namespace Ombi.Core.Engine
|
||||
{
|
||||
|
@ -26,8 +27,8 @@ namespace Ombi.Core.Engine
|
|||
{
|
||||
public TvSearchEngine(IPrincipal identity, IRequestServiceMain service, ITvMazeApi tvMaze, IMapper mapper, ISettingsService<PlexSettings> plexSettings,
|
||||
ISettingsService<EmbySettings> embySettings, IPlexContentRepository repo, IEmbyContentRepository embyRepo, ITraktApi trakt, IRuleEvaluator r, OmbiUserManager um,
|
||||
ICacheService memCache)
|
||||
: base(identity, service, r, um)
|
||||
ICacheService memCache, ISettingsService<OmbiSettings> s)
|
||||
: base(identity, service, r, um, memCache, s)
|
||||
{
|
||||
TvMazeApi = tvMaze;
|
||||
Mapper = mapper;
|
||||
|
@ -36,7 +37,6 @@ namespace Ombi.Core.Engine
|
|||
PlexContentRepo = repo;
|
||||
TraktApi = trakt;
|
||||
EmbyContentRepo = embyRepo;
|
||||
MemCache = memCache;
|
||||
}
|
||||
|
||||
private ITvMazeApi TvMazeApi { get; }
|
||||
|
@ -46,7 +46,6 @@ namespace Ombi.Core.Engine
|
|||
private IPlexContentRepository PlexContentRepo { get; }
|
||||
private IEmbyContentRepository EmbyContentRepo { get; }
|
||||
private ITraktApi TraktApi { get; }
|
||||
private ICacheService MemCache { get; }
|
||||
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> Search(string searchTerm)
|
||||
{
|
||||
|
@ -124,54 +123,55 @@ namespace Ombi.Core.Engine
|
|||
|
||||
public async Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> PopularTree()
|
||||
{
|
||||
var result = await MemCache.GetOrAdd(CacheKeys.PopularTv, async () => await TraktApi.GetPopularShows(), DateTime.Now.AddHours(12));
|
||||
var result = await Cache.GetOrAdd(CacheKeys.PopularTv, async () => await TraktApi.GetPopularShows(), DateTime.Now.AddHours(12));
|
||||
var processed = await ProcessResults(result);
|
||||
return processed.Select(ParseIntoTreeNode).ToList();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> Popular()
|
||||
{
|
||||
var result = await MemCache.GetOrAdd(CacheKeys.PopularTv, async () => await TraktApi.GetPopularShows(), DateTime.Now.AddHours(12));
|
||||
var result = await Cache.GetOrAdd(CacheKeys.PopularTv, async () => await TraktApi.GetPopularShows(), DateTime.Now.AddHours(12));
|
||||
var processed = await ProcessResults(result);
|
||||
return processed;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> AnticipatedTree()
|
||||
{
|
||||
var result = await MemCache.GetOrAdd(CacheKeys.AnticipatedTv, async () => await TraktApi.GetAnticipatedShows(), DateTime.Now.AddHours(12));
|
||||
var result = await Cache.GetOrAdd(CacheKeys.AnticipatedTv, async () => await TraktApi.GetAnticipatedShows(), DateTime.Now.AddHours(12));
|
||||
var processed = await ProcessResults(result);
|
||||
return processed.Select(ParseIntoTreeNode).ToList();
|
||||
}
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> Anticipated()
|
||||
{
|
||||
var result = await MemCache.GetOrAdd(CacheKeys.AnticipatedTv, async () => await TraktApi.GetAnticipatedShows(), DateTime.Now.AddHours(12));
|
||||
|
||||
var result = await Cache.GetOrAdd(CacheKeys.AnticipatedTv, async () => await TraktApi.GetAnticipatedShows(), DateTime.Now.AddHours(12));
|
||||
var processed = await ProcessResults(result);
|
||||
return processed;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> MostWatchesTree()
|
||||
{
|
||||
var result = await MemCache.GetOrAdd(CacheKeys.MostWatchesTv, async () => await TraktApi.GetMostWatchesShows(), DateTime.Now.AddHours(12));
|
||||
var result = await Cache.GetOrAdd(CacheKeys.MostWatchesTv, async () => await TraktApi.GetMostWatchesShows(), DateTime.Now.AddHours(12));
|
||||
var processed = await ProcessResults(result);
|
||||
return processed.Select(ParseIntoTreeNode).ToList();
|
||||
}
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> MostWatches()
|
||||
{
|
||||
var result = await MemCache.GetOrAdd(CacheKeys.MostWatchesTv, async () => await TraktApi.GetMostWatchesShows(), DateTime.Now.AddHours(12));
|
||||
var result = await Cache.GetOrAdd(CacheKeys.MostWatchesTv, async () => await TraktApi.GetMostWatchesShows(), DateTime.Now.AddHours(12));
|
||||
var processed = await ProcessResults(result);
|
||||
return processed;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<TreeNode<SearchTvShowViewModel>>> TrendingTree()
|
||||
{
|
||||
var result = await MemCache.GetOrAdd(CacheKeys.TrendingTv, async () => await TraktApi.GetTrendingShows(), DateTime.Now.AddHours(12));
|
||||
var result = await Cache.GetOrAdd(CacheKeys.TrendingTv, async () => await TraktApi.GetTrendingShows(), DateTime.Now.AddHours(12));
|
||||
var processed = await ProcessResults(result);
|
||||
return processed.Select(ParseIntoTreeNode).ToList();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> Trending()
|
||||
{
|
||||
var result = await MemCache.GetOrAdd(CacheKeys.TrendingTv, async () => await TraktApi.GetTrendingShows(), DateTime.Now.AddHours(12));
|
||||
var result = await Cache.GetOrAdd(CacheKeys.TrendingTv, async () => await TraktApi.GetTrendingShows(), DateTime.Now.AddHours(12));
|
||||
var processed = await ProcessResults(result);
|
||||
return processed;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace Ombi.Helpers
|
|||
var version = Assembly.GetEntryAssembly()
|
||||
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
|
||||
.InformationalVersion;
|
||||
return version.Equals("1.0.0") ? "3.0.0-DotNetCore" : version;
|
||||
return version.Equals("1.0.0") ? "3.0.0-develop" : version;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@
|
|||
public string ApiKey { get; set; }
|
||||
public bool IgnoreCertificateErrors { get; set; }
|
||||
public bool DoNotSendNotificationsForAutoApprove { get; set; }
|
||||
public bool HideRequestsUsers { get; set; }
|
||||
|
||||
}
|
||||
}
|
|
@ -11,5 +11,7 @@ namespace Ombi.Store.Repository.Requests
|
|||
Task Update(MovieRequests request);
|
||||
Task Save();
|
||||
IQueryable<MovieRequests> GetWithUser();
|
||||
IQueryable<MovieRequests> GetWithUser(string userId);
|
||||
IQueryable<MovieRequests> GetAll(string userId);
|
||||
}
|
||||
}
|
|
@ -14,11 +14,13 @@ namespace Ombi.Store.Repository.Requests
|
|||
Task Delete(TvRequests request);
|
||||
Task DeleteChild(ChildRequests request);
|
||||
IQueryable<TvRequests> Get();
|
||||
IQueryable<TvRequests> Get(string userId);
|
||||
Task<TvRequests> GetRequestAsync(int tvDbId);
|
||||
TvRequests GetRequest(int tvDbId);
|
||||
Task Update(TvRequests request);
|
||||
Task UpdateChild(ChildRequests request);
|
||||
IQueryable<ChildRequests> GetChild();
|
||||
IQueryable<ChildRequests> GetChild(string userId);
|
||||
Task Save();
|
||||
Task DeleteChildRange(IEnumerable<ChildRequests> request);
|
||||
}
|
||||
|
|
|
@ -33,6 +33,11 @@ namespace Ombi.Store.Repository.Requests
|
|||
|
||||
}
|
||||
|
||||
public IQueryable<MovieRequests> GetAll(string userId)
|
||||
{
|
||||
return GetWithUser().Where(x => x.RequestedUserId == userId);
|
||||
}
|
||||
|
||||
public MovieRequests GetRequest(int theMovieDbId)
|
||||
{
|
||||
return Db.MovieRequests.Where(x => x.TheMovieDbId == theMovieDbId)
|
||||
|
@ -48,6 +53,16 @@ namespace Ombi.Store.Repository.Requests
|
|||
.AsQueryable();
|
||||
}
|
||||
|
||||
|
||||
public IQueryable<MovieRequests> GetWithUser(string userId)
|
||||
{
|
||||
return Db.MovieRequests
|
||||
.Where(x => x.RequestedUserId == userId)
|
||||
.Include(x => x.RequestedUser)
|
||||
.ThenInclude(x => x.NotificationUserIds)
|
||||
.AsQueryable();
|
||||
}
|
||||
|
||||
public async Task Update(MovieRequests request)
|
||||
{
|
||||
if (Db.Entry(request).State == EntityState.Detached)
|
||||
|
|
|
@ -48,6 +48,18 @@ namespace Ombi.Store.Repository.Requests
|
|||
.ThenInclude(x => x.Episodes)
|
||||
.AsQueryable();
|
||||
}
|
||||
|
||||
public IQueryable<TvRequests> Get(string userId)
|
||||
{
|
||||
return Db.TvRequests
|
||||
.Include(x => x.ChildRequests)
|
||||
.ThenInclude(x => x.RequestedUser)
|
||||
.Include(x => x.ChildRequests)
|
||||
.ThenInclude(x => x.SeasonRequests)
|
||||
.ThenInclude(x => x.Episodes)
|
||||
.Where(x => x.ChildRequests.Any(a => a.RequestedUserId == userId))
|
||||
.AsQueryable();
|
||||
}
|
||||
public IQueryable<ChildRequests> GetChild()
|
||||
{
|
||||
return Db.ChildRequests
|
||||
|
@ -58,6 +70,17 @@ namespace Ombi.Store.Repository.Requests
|
|||
.AsQueryable();
|
||||
}
|
||||
|
||||
public IQueryable<ChildRequests> GetChild(string userId)
|
||||
{
|
||||
return Db.ChildRequests
|
||||
.Where(x => x.RequestedUserId == userId)
|
||||
.Include(x => x.RequestedUser)
|
||||
.Include(x => x.ParentRequest)
|
||||
.Include(x => x.SeasonRequests)
|
||||
.ThenInclude(x => x.Episodes)
|
||||
.AsQueryable();
|
||||
}
|
||||
|
||||
public async Task Save()
|
||||
{
|
||||
await Db.SaveChangesAsync();
|
||||
|
|
|
@ -14,6 +14,7 @@ export interface IOmbiSettings extends ISettings {
|
|||
apiKey: string;
|
||||
ignoreCertificateErrors: boolean;
|
||||
doNotSendNotificationsForAutoApprove: boolean;
|
||||
hideRequestsUsers: boolean;
|
||||
}
|
||||
|
||||
export interface IUpdateSettings extends ISettings {
|
||||
|
|
|
@ -199,6 +199,13 @@
|
|||
<label for="Processing">{{ 'Common.ProcessingRequest' | translate }}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="radio">
|
||||
<input type="radio" id="approved" name="Status" (click)="filterStatus(filterType.PendingApproval)">
|
||||
<label for="approved">{{ 'Filter.PendingApproval' | translate }}</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<button class="btn btn-sm btn-primary-outline" (click)="clearFilter()">
|
||||
<i class="fa fa-filter"></i> {{ 'Filter.ClearFilter' | translate }}</button>
|
||||
|
|
|
@ -53,6 +53,14 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="checkbox">
|
||||
<input type="checkbox" id="hideRequestsUsers" name="hideRequestsUsers" formControlName="hideRequestsUsers">
|
||||
<label for="hideRequestsUsers">Hide requests from other users</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<div class="checkbox">
|
||||
<input type="checkbox" id="ignoreCertificateErrors" name="ignoreCertificateErrors" formControlName="ignoreCertificateErrors">
|
||||
|
|
|
@ -24,6 +24,7 @@ export class OmbiComponent implements OnInit {
|
|||
ignoreCertificateErrors: [x.ignoreCertificateErrors],
|
||||
baseUrl: [x.baseUrl],
|
||||
doNotSendNotificationsForAutoApprove: [x.doNotSendNotificationsForAutoApprove],
|
||||
hideRequestsUsers: [x.hideRequestsUsers],
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -334,9 +334,9 @@ namespace Ombi.Controllers
|
|||
/// <param name="vm"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("movie/filter")]
|
||||
public IEnumerable<MovieRequests> Filter([FromBody] FilterViewModel vm)
|
||||
public async Task<IEnumerable<MovieRequests>> Filter([FromBody] FilterViewModel vm)
|
||||
{
|
||||
return MovieRequestEngine.Filter(vm);
|
||||
return await MovieRequestEngine.Filter(vm);
|
||||
}
|
||||
}
|
||||
}
|
BIN
src/Ombi/Ombi.testdb
Normal file
BIN
src/Ombi/Ombi.testdb
Normal file
Binary file not shown.
|
@ -21,7 +21,11 @@
|
|||
"Request": "Anmod",
|
||||
"Denied": "Afvist",
|
||||
"Approve": "Godkendt",
|
||||
<<<<<<< HEAD
|
||||
"PartlyAvailable": "Delvist tilgængelig",
|
||||
=======
|
||||
"PartlyAvailable": "Partly Available",
|
||||
>>>>>>> New translations en.json (Danish)
|
||||
"Errors": {
|
||||
"Validation": "Tjek venligst dine indtastede værdier"
|
||||
}
|
||||
|
@ -87,6 +91,7 @@
|
|||
"Trailer": "Trailer"
|
||||
},
|
||||
"TvShows": {
|
||||
<<<<<<< HEAD
|
||||
"Popular": "Populære",
|
||||
"Trending": "Aktuelle",
|
||||
"MostWatched": "Mest sete",
|
||||
|
@ -100,6 +105,18 @@
|
|||
"SubmitRequest": "Send anmodning",
|
||||
"Season": "Sæson: {{seasonNumber}}",
|
||||
"SelectAllInSeason": "Vælg alle i sæson {{seasonNumber}}"
|
||||
=======
|
||||
"Popular": "Popular",
|
||||
"Trending": "Trending",
|
||||
"MostWatched": "Most Watched",
|
||||
"MostAnticipated": "Most Anticipated",
|
||||
"Results": "Results",
|
||||
"AirDate": "Air Date:",
|
||||
"AllSeasons": "All Seasons",
|
||||
"FirstSeason": "First Season",
|
||||
"LatestSeason": "Latest Season",
|
||||
"Select": "Select ..."
|
||||
>>>>>>> New translations en.json (Danish)
|
||||
}
|
||||
},
|
||||
"Requests": {
|
||||
|
|
|
@ -158,6 +158,7 @@
|
|||
"ClearFilter":"Clear Filter",
|
||||
"FilterHeaderAvailability":"Availability",
|
||||
"FilterHeaderRequestStatus":"Status",
|
||||
"Approved":"Approved"
|
||||
"Approved":"Approved",
|
||||
"PendingApproval": "Pending Approval"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue