|
|
|
@ -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)
|
|
|
|
|
{
|
|
|
|
|