mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-12 16:22:55 -07:00
Added the subscribe button to the search page if we have an existing request.
This commit is contained in:
parent
e8249fa1a8
commit
a82b011ae3
8 changed files with 60 additions and 6 deletions
|
@ -9,6 +9,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Security.Principal;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Ombi.Core.Rule.Interfaces;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Ombi.Core.Authentication;
|
||||
|
@ -166,10 +167,31 @@ namespace Ombi.Core.Engine
|
|||
viewMovie.TheMovieDbId = viewMovie.Id.ToString();
|
||||
|
||||
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();
|
||||
var request = await RequestService.MovieRequestService.GetAll()
|
||||
.AnyAsync(x => x.RequestedUserId.Equals(user.Id) && x.Id == 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;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<SearchMovieViewModel> ProcessSingleMovie(MovieSearchResult movie)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue