From 25342ec3c25fae3028f30beabfcd84afd24ae430 Mon Sep 17 00:00:00 2001 From: sephrat <34862846+sephrat@users.noreply.github.com> Date: Fri, 8 Apr 2022 16:20:55 +0200 Subject: [PATCH 1/8] Lint it first --- .../movie/movie-details.component.html | 218 ++++++++++-------- 1 file changed, 122 insertions(+), 96 deletions(-) diff --git a/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html b/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html index d3997fb1c..adff7acc1 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html @@ -4,30 +4,18 @@
- +
- +
@@ -43,118 +31,146 @@
- + {{'Search.ViewOnPlex' | translate}} - + {{'Search.ViewOnEmby' | translate}} - + {{'Search.ViewOnJellyfin' | translate}} - - - - - - - - - + + + + + + + + + - - + + - - + - - - - - - + - - + + + + + + + - - - - - - - - - - - - - - - - + + + +
@@ -163,7 +179,8 @@
- + @@ -199,9 +216,14 @@ {{'MediaDetails.Trailers' | translate}} - + - + @@ -229,7 +251,9 @@ @@ -249,7 +273,9 @@ From 614f9b3b21cb1b4d7a5873903db99c5d6f18e999 Mon Sep 17 00:00:00 2001 From: sephrat <34862846+sephrat@users.noreply.github.com> Date: Fri, 8 Apr 2022 16:21:39 +0200 Subject: [PATCH 2/8] Fix subscribe button displayed only if 4K is enabled --- .../movie/movie-details.component.html | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html b/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html index adff7acc1..a7b4df576 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html @@ -104,17 +104,18 @@ {{'Common.Request4K' | translate }} - - - - + + + + + - From 6c8205ffc8e3c8f9756282b4f8912f33962c2d4e Mon Sep 17 00:00:00 2001 From: sephrat <34862846+sephrat@users.noreply.github.com> Date: Fri, 8 Apr 2022 17:15:27 +0200 Subject: [PATCH 6/8] Allow admins to subscribe too! --- .../media-details/components/movie/movie-details.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html b/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html index 597c4d52f..add339ad8 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html @@ -108,7 +108,7 @@ - + From da0404d5528dcd9a6217199632068d0d40672ea5 Mon Sep 17 00:00:00 2001 From: sephrat <34862846+sephrat@users.noreply.github.com> Date: Fri, 8 Apr 2022 17:18:41 +0200 Subject: [PATCH 7/8] Fix regression when request is not made --- .../components/movie/movie-details.component.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html b/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html index add339ad8..2207ea323 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html @@ -108,11 +108,11 @@ - - - From 10a7f8d4fb705adedd492d6e6197f49fca2194c4 Mon Sep 17 00:00:00 2001 From: sephrat <34862846+sephrat@users.noreply.github.com> Date: Sat, 9 Apr 2022 09:19:42 +0200 Subject: [PATCH 8/8] Restore Subscribed field in search service Let's only flag it as obsolete for now --- src/Ombi.Core/Engine/MovieSearchEngine.cs | 26 ++++++++++++++++ .../Engine/V2/MovieSearchEngineV2.cs | 31 +++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/src/Ombi.Core/Engine/MovieSearchEngine.cs b/src/Ombi.Core/Engine/MovieSearchEngine.cs index 76cb13968..682a999eb 100644 --- a/src/Ombi.Core/Engine/MovieSearchEngine.cs +++ b/src/Ombi.Core/Engine/MovieSearchEngine.cs @@ -16,6 +16,7 @@ using Ombi.Store.Repository; using System; using System.Collections.Generic; using System.Linq; +using System.Security.Principal; using System.Threading.Tasks; namespace Ombi.Core.Engine @@ -215,9 +216,34 @@ namespace Ombi.Core.Engine await RunSearchRules(viewMovie); + // This requires the rules to be run first to populate the RequestId property + await CheckForSubscription(viewMovie); + return viewMovie; } + private async Task CheckForSubscription(SearchMovieViewModel viewModel) + { + // Check if this user requested it + var user = await GetUser(); + if (user == null) + { + return; + } + var request = await RequestService.MovieRequestService.GetAll() + .AnyAsync(x => x.RequestedUserId.Equals(user.Id) && x.TheMovieDbId == viewModel.Id); + if (request || viewModel.Available) + { + viewModel.ShowSubscribe = false; + } + else + { + viewModel.ShowSubscribe = true; + var sub = await _subscriptionRepository.GetAll().FirstOrDefaultAsync(s => s.UserId == user.Id + && s.RequestId == viewModel.RequestId && s.RequestType == RequestType.Movie); + viewModel.Subscribed = sub != null; + } + } private async Task ProcessSingleMovie(MovieDbSearchResult movie) { diff --git a/src/Ombi.Core/Engine/V2/MovieSearchEngineV2.cs b/src/Ombi.Core/Engine/V2/MovieSearchEngineV2.cs index 614c2df55..3acd7d1f0 100644 --- a/src/Ombi.Core/Engine/V2/MovieSearchEngineV2.cs +++ b/src/Ombi.Core/Engine/V2/MovieSearchEngineV2.cs @@ -393,6 +393,8 @@ namespace Ombi.Core.Engine.V2 await RunSearchRules(viewMovie); + // This requires the rules to be run first to populate the RequestId property + await CheckForSubscription(viewMovie); var mapped = Mapper.Map(movie); mapped.Available = viewMovie.Available; @@ -404,6 +406,7 @@ namespace Ombi.Core.Engine.V2 mapped.PlexUrl = viewMovie.PlexUrl; mapped.EmbyUrl = viewMovie.EmbyUrl; mapped.JellyfinUrl = viewMovie.JellyfinUrl; + mapped.Subscribed = viewMovie.Subscribed; mapped.ShowSubscribe = viewMovie.ShowSubscribe; mapped.DigitalReleaseDate = viewMovie.DigitalReleaseDate; mapped.RequestedDate4k = viewMovie.RequestedDate4k; @@ -426,6 +429,8 @@ namespace Ombi.Core.Engine.V2 var mappedMovie = Mapper.Map(movie); await RunSearchRules(mappedMovie); + // This requires the rules to be run first to populate the RequestId property + await CheckForSubscription(mappedMovie); var mapped = Mapper.Map(movie); mapped.Available = movie.Available; @@ -435,6 +440,7 @@ namespace Ombi.Core.Engine.V2 mapped.PlexUrl = movie.PlexUrl; mapped.EmbyUrl = movie.EmbyUrl; mapped.JellyfinUrl = movie.JellyfinUrl; + mapped.Subscribed = movie.Subscribed; mapped.ShowSubscribe = movie.ShowSubscribe; mapped.ReleaseDate = movie.ReleaseDate; } @@ -464,9 +470,34 @@ namespace Ombi.Core.Engine.V2 await RunSearchRules(viewMovie); + // This requires the rules to be run first to populate the RequestId property + await CheckForSubscription(viewMovie); + return viewMovie; } + private async Task CheckForSubscription(SearchViewModel viewModel) + { + // Check if this user requested it + var user = await GetUser(); + if (user == null) + { + return; + } + var request = await RequestService.MovieRequestService.GetAll() + .AnyAsync(x => x.RequestedUserId.Equals(user.Id) && x.TheMovieDbId == viewModel.Id); + if (request) + { + viewModel.ShowSubscribe = false; + } + else + { + viewModel.ShowSubscribe = true; + var sub = await _subscriptionRepository.GetAll().FirstOrDefaultAsync(s => s.UserId == user.Id + && s.RequestId == viewModel.RequestId && s.RequestType == RequestType.Movie); + viewModel.Subscribed = sub != null; + } + } public async Task GetMovieInfoByImdbId(string imdbId, CancellationToken cancellationToken) {