diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e6153b88..e58c1429a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## (unreleased) +## v3.0.3000 (2018-03-09) ### **New Features** @@ -8,6 +8,12 @@ - Added Pending Approval into the filters list. [tidusjar] +- Added the ability to hide requests that have not been made by that user (#2052) [Jamie] + +- Update README.md. [Jamie] + +- Update README.md. [Louis Laureys] + ### **Fixes** - Fixed #2042. [Jamie] diff --git a/README.md b/README.md index b8f98f2d9..3a037145c 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,11 @@ ___ [![Report a bug](http://i.imgur.com/xSpw482.png)](https://forums.ombi.io/viewforum.php?f=10) [![Feature request](http://i.imgur.com/mFO0OuX.png)](https://forums.ombi.io/posting.php?mode=post&f=20) -| Service | V3 | Beta | + +| Service | Stable | Develop | |----------|:---------------------------:|:----------------------------:| -| AppVeyor | [![Build status](https://ci.appveyor.com/api/projects/status/hgj8j6lcea7j0yhn/branch/master?svg=true)](https://ci.appveyor.com/project/tidusjar/requestplex/branch/master) | [![Build status](https://ci.appveyor.com/api/projects/status/hgj8j6lcea7j0yhn/branch/DotNetCore?svg=true)](https://ci.appveyor.com/project/tidusjar/requestplex/branch/DotNetCore) | -| Download |[![Download](http://i.imgur.com/odToka3.png)](https://github.com/tidusjar/Ombi/releases) | [![Download](http://i.imgur.com/odToka3.png)](https://ci.appveyor.com/project/tidusjar/requestplex/branch/DotNetCore/artifacts) | +| AppVeyor | [![Build status](https://ci.appveyor.com/api/projects/status/hgj8j6lcea7j0yhn/branch/master?svg=true)](https://ci.appveyor.com/project/tidusjar/requestplex/branch/master) | [![Build status](https://ci.appveyor.com/api/projects/status/hgj8j6lcea7j0yhn/branch/develop?svg=true)](https://ci.appveyor.com/project/tidusjar/requestplex/branch/develop) | +| Download |[![Download](http://i.imgur.com/odToka3.png)](https://github.com/tidusjar/Ombi/releases) | [![Download](http://i.imgur.com/odToka3.png)](https://ci.appveyor.com/project/tidusjar/requestplex/branch/develop/artifacts) | # Features Here are some of the features Ombi V3 has: * Now working without crashes on Linux. @@ -91,9 +92,9 @@ Search the existing requests to see if your suggestion has already been submitte # Installation -[Click Here](https://github.com/tidusjar/Ombi/wiki/Installation) -[Here for Reverse Proxy Config Examples](https://github.com/tidusjar/Ombi/wiki/Reverse-Proxy-Examples) -[PlexGuide.com - Ombi Deployment & 101 Demonstration!](https://www.youtube.com/watch?v=QPNlqqkjNJw&feature=youtu.be) +[Installation Guide](https://github.com/tidusjar/Ombi/wiki/Installation) +[Here for Reverse Proxy Config Examples](https://github.com/tidusjar/Ombi/wiki/Reverse-Proxy-Examples) +[PlexGuide.com - Ombi Deployment & 101 Demonstration!](https://www.youtube.com/watch?v=QPNlqqkjNJw&feature=youtu.be) # Contributors diff --git a/src/Ombi.Core/Engine/BaseMediaEngine.cs b/src/Ombi.Core/Engine/BaseMediaEngine.cs index 213659700..552b2ac38 100644 --- a/src/Ombi.Core/Engine/BaseMediaEngine.cs +++ b/src/Ombi.Core/Engine/BaseMediaEngine.cs @@ -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 _dbTv; protected BaseMediaEngine(IPrincipal identity, IRequestServiceMain requestService, - IRuleEvaluator rules, OmbiUserManager um) : base(identity, um, rules) + IRuleEvaluator rules, OmbiUserManager um, ICacheService cache, ISettingsService 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; protected async Task> GetMovieRequests() { @@ -99,5 +105,30 @@ namespace Ombi.Core.Engine Pending = pendingMovies + pendingTv }; } + + protected async Task 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; } + } } } \ No newline at end of file diff --git a/src/Ombi.Core/Engine/Interfaces/IMovieRequestEngine.cs b/src/Ombi.Core/Engine/Interfaces/IMovieRequestEngine.cs index 2163784cf..bfeb4fbe0 100644 --- a/src/Ombi.Core/Engine/Interfaces/IMovieRequestEngine.cs +++ b/src/Ombi.Core/Engine/Interfaces/IMovieRequestEngine.cs @@ -17,6 +17,6 @@ namespace Ombi.Core.Engine.Interfaces Task ApproveMovie(MovieRequests request); Task ApproveMovieById(int requestId); Task DenyMovieById(int modelId); - IEnumerable Filter(FilterViewModel vm); + Task> Filter(FilterViewModel vm); } } \ No newline at end of file diff --git a/src/Ombi.Core/Engine/MovieRequestEngine.cs b/src/Ombi.Core/Engine/MovieRequestEngine.cs index 451820ebb..0b376386f 100644 --- a/src/Ombi.Core/Engine/MovieRequestEngine.cs +++ b/src/Ombi.Core/Engine/MovieRequestEngine.cs @@ -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 log, - OmbiUserManager manager, IRepository rl) : base(user, requestService, r, manager) + OmbiUserManager manager, IRepository rl, ICacheService cache, ISettingsService ombiSettings) : base(user, requestService, r, manager, cache, ombiSettings) { MovieApi = movieApi; NotificationHelper = helper; @@ -110,7 +111,7 @@ namespace Ombi.Core.Engine return requestEngineResult; } - + // If there are no providers then it's successful but movie has not been sent } @@ -126,7 +127,16 @@ namespace Ombi.Core.Engine /// public async Task> GetRequests(int count, int position) { - var allRequests = await MovieRepository.GetWithUser().Skip(position).Take(count).ToListAsync(); + var shouldHide = await HideFromOtherUsers(); + List 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 /// public async Task> GetRequests() { - var allRequests = await MovieRepository.GetWithUser().ToListAsync(); + var shouldHide = await HideFromOtherUsers(); + List 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 /// public async Task> SearchMovieRequest(string search) { - var allRequests = await MovieRepository.GetWithUser().ToListAsync(); + var shouldHide = await HideFromOtherUsers(); + List 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 => { @@ -159,7 +187,7 @@ namespace Ombi.Core.Engine }); return results; } - + public async Task ApproveMovieById(int requestId) { var request = await MovieRepository.Find(requestId); @@ -179,7 +207,7 @@ namespace Ombi.Core.Engine request.Denied = true; // We are denying a request NotificationHelper.Notify(request, NotificationType.RequestDeclined); - await MovieRepository.Update(request); + await MovieRepository.Update(request); return new RequestEngineResult { @@ -339,9 +367,10 @@ namespace Ombi.Core.Engine return new RequestEngineResult { Result = true, Message = $"{movieName} has been successfully added!" }; } - public IEnumerable Filter(FilterViewModel vm) + public async Task> 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: diff --git a/src/Ombi.Core/Engine/MovieSearchEngine.cs b/src/Ombi.Core/Engine/MovieSearchEngine.cs index 33107e5af..448ff9235 100644 --- a/src/Ombi.Core/Engine/MovieSearchEngine.cs +++ b/src/Ombi.Core/Engine/MovieSearchEngine.cs @@ -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 logger, IRuleEvaluator r, OmbiUserManager um, ICacheService mem) - : base(identity, service, r, um) + ILogger logger, IRuleEvaluator r, OmbiUserManager um, ICacheService mem, ISettingsService 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 Logger { get; } - private ICacheService MemCache { get; } /// /// Lookups the imdb information. @@ -85,7 +85,7 @@ namespace Ombi.Core.Engine /// public async Task> 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 /// public async Task> 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 /// public async Task> 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 /// public async Task> 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); diff --git a/src/Ombi.Core/Engine/TvRequestEngine.cs b/src/Ombi.Core/Engine/TvRequestEngine.cs index 16333800b..f8fc33e9b 100644 --- a/src/Ombi.Core/Engine/TvRequestEngine.cs +++ b/src/Ombi.Core/Engine/TvRequestEngine.cs @@ -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 rl) : base(user, requestService, rule, manager) + ITvSender sender, IAuditRepository audit, IRepository rl, ISettingsService 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> GetRequests(int count, int position) { - var allRequests = await TvRepository.Get() - .Include(x => x.ChildRequests) + var shouldHide = await HideFromOtherUsers(); + List 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(); + .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>>> GetRequestsTreeNode(int count, int position) { - var allRequests = await TvRepository.Get() - .Include(x => x.ChildRequests) + var shouldHide = await HideFromOtherUsers(); + List 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(); + .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> GetRequests() { - var allRequests = TvRepository.Get(); + var shouldHide = await HideFromOtherUsers(); + IQueryable 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 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> GetAllChldren(int tvId) { - return await TvRepository.GetChild().Include(x => x.SeasonRequests).Where(x => x.ParentRequestId == tvId).ToListAsync(); + var shouldHide = await HideFromOtherUsers(); + List 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> SearchTvRequest(string search) { - var allRequests = TvRepository.Get(); + var shouldHide = await HideFromOtherUsers(); + IQueryable 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>>> SearchTvRequestTree(string search) { - var allRequests = TvRepository.Get(); + var shouldHide = await HideFromOtherUsers(); + IQueryable 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); } @@ -402,7 +495,7 @@ namespace Ombi.Core.Engine var result = await TvSender.Send(model); if (result.Success) { - return new RequestEngineResult {Result = true}; + return new RequestEngineResult { Result = true }; } return new RequestEngineResult { @@ -418,7 +511,7 @@ namespace Ombi.Core.Engine RequestType = RequestType.TvShow, }); - return new RequestEngineResult {Result = true}; + return new RequestEngineResult { Result = true }; } } } \ No newline at end of file diff --git a/src/Ombi.Core/Engine/TvSearchEngine.cs b/src/Ombi.Core/Engine/TvSearchEngine.cs index 56000d00a..1664ecfa7 100644 --- a/src/Ombi.Core/Engine/TvSearchEngine.cs +++ b/src/Ombi.Core/Engine/TvSearchEngine.cs @@ -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, ISettingsService embySettings, IPlexContentRepository repo, IEmbyContentRepository embyRepo, ITraktApi trakt, IRuleEvaluator r, OmbiUserManager um, - ICacheService memCache) - : base(identity, service, r, um) + ICacheService memCache, ISettingsService 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> Search(string searchTerm) { @@ -124,54 +123,55 @@ namespace Ombi.Core.Engine public async Task>> 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> 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>> AnticipatedTree() + public async Task>> 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> 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>> 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> 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>> 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> 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; } diff --git a/src/Ombi.Helpers/AssemblyHelper.cs b/src/Ombi.Helpers/AssemblyHelper.cs index 5d3bb5bf5..d2c266369 100644 --- a/src/Ombi.Helpers/AssemblyHelper.cs +++ b/src/Ombi.Helpers/AssemblyHelper.cs @@ -9,7 +9,7 @@ namespace Ombi.Helpers var version = Assembly.GetEntryAssembly() .GetCustomAttribute() .InformationalVersion; - return version.Equals("1.0.0") ? "3.0.0-DotNetCore" : version; + return version.Equals("1.0.0") ? "3.0.0-develop" : version; } } } \ No newline at end of file diff --git a/src/Ombi.Schedule/Processor/ChangeLogProcessor.cs b/src/Ombi.Schedule/Processor/ChangeLogProcessor.cs index f1c0925aa..09ceed5d3 100644 --- a/src/Ombi.Schedule/Processor/ChangeLogProcessor.cs +++ b/src/Ombi.Schedule/Processor/ChangeLogProcessor.cs @@ -46,8 +46,7 @@ namespace Ombi.Schedule.Processor if (masterBranch) { latestRelease = doc.DocumentNode.Descendants("h2") - .FirstOrDefault(x => x.InnerText == "(unreleased)"); - // TODO: Change this to InnterText != "(unreleased)" once we go live and it's not a prerelease + .FirstOrDefault(x => x.InnerText != "(unreleased)"); } else { diff --git a/src/Ombi.Settings/Settings/Models/OmbiSettings.cs b/src/Ombi.Settings/Settings/Models/OmbiSettings.cs index ee9d5943b..bf4d29eb4 100644 --- a/src/Ombi.Settings/Settings/Models/OmbiSettings.cs +++ b/src/Ombi.Settings/Settings/Models/OmbiSettings.cs @@ -7,7 +7,8 @@ public bool Wizard { get; set; } public string ApiKey { get; set; } public bool IgnoreCertificateErrors { get; set; } - public bool DoNotSendNotificationsForAutoApprove {get;set;} + public bool DoNotSendNotificationsForAutoApprove { get; set; } + public bool HideRequestsUsers { get; set; } } } \ No newline at end of file diff --git a/src/Ombi.Store/Repository/Requests/IMovieRequestRepository.cs b/src/Ombi.Store/Repository/Requests/IMovieRequestRepository.cs index e25b2b168..275937360 100644 --- a/src/Ombi.Store/Repository/Requests/IMovieRequestRepository.cs +++ b/src/Ombi.Store/Repository/Requests/IMovieRequestRepository.cs @@ -11,5 +11,7 @@ namespace Ombi.Store.Repository.Requests Task Update(MovieRequests request); Task Save(); IQueryable GetWithUser(); + IQueryable GetWithUser(string userId); + IQueryable GetAll(string userId); } } \ No newline at end of file diff --git a/src/Ombi.Store/Repository/Requests/ITvRequestRepository.cs b/src/Ombi.Store/Repository/Requests/ITvRequestRepository.cs index 46d2c0bf6..749b67c73 100644 --- a/src/Ombi.Store/Repository/Requests/ITvRequestRepository.cs +++ b/src/Ombi.Store/Repository/Requests/ITvRequestRepository.cs @@ -14,11 +14,13 @@ namespace Ombi.Store.Repository.Requests Task Delete(TvRequests request); Task DeleteChild(ChildRequests request); IQueryable Get(); + IQueryable Get(string userId); Task GetRequestAsync(int tvDbId); TvRequests GetRequest(int tvDbId); Task Update(TvRequests request); Task UpdateChild(ChildRequests request); IQueryable GetChild(); + IQueryable GetChild(string userId); Task Save(); Task DeleteChildRange(IEnumerable request); } diff --git a/src/Ombi.Store/Repository/Requests/MovieRequestRepository.cs b/src/Ombi.Store/Repository/Requests/MovieRequestRepository.cs index 19a89a835..78c3da7dd 100644 --- a/src/Ombi.Store/Repository/Requests/MovieRequestRepository.cs +++ b/src/Ombi.Store/Repository/Requests/MovieRequestRepository.cs @@ -33,6 +33,11 @@ namespace Ombi.Store.Repository.Requests } + public IQueryable 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 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) diff --git a/src/Ombi.Store/Repository/Requests/TvRequestRepository.cs b/src/Ombi.Store/Repository/Requests/TvRequestRepository.cs index 216058d67..28a141908 100644 --- a/src/Ombi.Store/Repository/Requests/TvRequestRepository.cs +++ b/src/Ombi.Store/Repository/Requests/TvRequestRepository.cs @@ -48,6 +48,18 @@ namespace Ombi.Store.Repository.Requests .ThenInclude(x => x.Episodes) .AsQueryable(); } + + public IQueryable 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 GetChild() { return Db.ChildRequests @@ -58,6 +70,17 @@ namespace Ombi.Store.Repository.Requests .AsQueryable(); } + public IQueryable 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(); diff --git a/src/Ombi/ClientApp/app/interfaces/ISettings.ts b/src/Ombi/ClientApp/app/interfaces/ISettings.ts index c7bb3ac37..950316316 100644 --- a/src/Ombi/ClientApp/app/interfaces/ISettings.ts +++ b/src/Ombi/ClientApp/app/interfaces/ISettings.ts @@ -14,6 +14,7 @@ export interface IOmbiSettings extends ISettings { apiKey: string; ignoreCertificateErrors: boolean; doNotSendNotificationsForAutoApprove: boolean; + hideRequestsUsers: boolean; } export interface IUpdateSettings extends ISettings { diff --git a/src/Ombi/ClientApp/app/settings/ombi/ombi.component.html b/src/Ombi/ClientApp/app/settings/ombi/ombi.component.html index 27ac016c6..3be162a9d 100644 --- a/src/Ombi/ClientApp/app/settings/ombi/ombi.component.html +++ b/src/Ombi/ClientApp/app/settings/ombi/ombi.component.html @@ -53,6 +53,14 @@ +
+
+ + +
+
+ +
diff --git a/src/Ombi/ClientApp/app/settings/ombi/ombi.component.ts b/src/Ombi/ClientApp/app/settings/ombi/ombi.component.ts index e8a3f9e80..d1832d7de 100644 --- a/src/Ombi/ClientApp/app/settings/ombi/ombi.component.ts +++ b/src/Ombi/ClientApp/app/settings/ombi/ombi.component.ts @@ -24,6 +24,7 @@ export class OmbiComponent implements OnInit { ignoreCertificateErrors: [x.ignoreCertificateErrors], baseUrl: [x.baseUrl], doNotSendNotificationsForAutoApprove: [x.doNotSendNotificationsForAutoApprove], + hideRequestsUsers: [x.hideRequestsUsers], }); }); } diff --git a/src/Ombi/Controllers/RequestController.cs b/src/Ombi/Controllers/RequestController.cs index bc73fb5df..d5c173d35 100644 --- a/src/Ombi/Controllers/RequestController.cs +++ b/src/Ombi/Controllers/RequestController.cs @@ -334,9 +334,9 @@ namespace Ombi.Controllers /// /// [HttpPost("movie/filter")] - public IEnumerable Filter([FromBody] FilterViewModel vm) + public async Task> Filter([FromBody] FilterViewModel vm) { - return MovieRequestEngine.Filter(vm); + return await MovieRequestEngine.Filter(vm); } } } \ No newline at end of file diff --git a/src/Ombi/Ombi.testdb b/src/Ombi/Ombi.testdb new file mode 100644 index 000000000..c96d58f51 Binary files /dev/null and b/src/Ombi/Ombi.testdb differ diff --git a/src/Ombi/wwwroot/translations/da.json b/src/Ombi/wwwroot/translations/da.json index ec4b0bce5..9c52a8a4d 100644 --- a/src/Ombi/wwwroot/translations/da.json +++ b/src/Ombi/wwwroot/translations/da.json @@ -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": {