|
|
@ -8,6 +8,7 @@ using System.Collections.Generic;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Ombi.Store.Entities.Requests;
|
|
|
|
using Ombi.Store.Entities.Requests;
|
|
|
|
using System.Diagnostics;
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
using Ombi.Attributes;
|
|
|
|
using Ombi.Attributes;
|
|
|
|
using Ombi.Core.Models.UI;
|
|
|
|
using Ombi.Core.Models.UI;
|
|
|
|
using Ombi.Models;
|
|
|
|
using Ombi.Models;
|
|
|
@ -21,14 +22,19 @@ namespace Ombi.Controllers
|
|
|
|
[Produces("application/json")]
|
|
|
|
[Produces("application/json")]
|
|
|
|
public class RequestController : Controller
|
|
|
|
public class RequestController : Controller
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public RequestController(IMovieRequestEngine engine, ITvRequestEngine tvRequestEngine)
|
|
|
|
public RequestController(IMovieRequestEngine engine, ITvRequestEngine tvRequestEngine, IVoteEngine vote,
|
|
|
|
|
|
|
|
ILogger<RequestController> log)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MovieRequestEngine = engine;
|
|
|
|
MovieRequestEngine = engine;
|
|
|
|
TvRequestEngine = tvRequestEngine;
|
|
|
|
TvRequestEngine = tvRequestEngine;
|
|
|
|
|
|
|
|
VoteEngine = vote;
|
|
|
|
|
|
|
|
Log = log;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private IMovieRequestEngine MovieRequestEngine { get; }
|
|
|
|
private IMovieRequestEngine MovieRequestEngine { get; }
|
|
|
|
private ITvRequestEngine TvRequestEngine { get; }
|
|
|
|
private ITvRequestEngine TvRequestEngine { get; }
|
|
|
|
|
|
|
|
private IVoteEngine VoteEngine { get; }
|
|
|
|
|
|
|
|
private ILogger Log { get; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Gets movie requests.
|
|
|
|
/// Gets movie requests.
|
|
|
@ -75,7 +81,17 @@ namespace Ombi.Controllers
|
|
|
|
[HttpPost("movie")]
|
|
|
|
[HttpPost("movie")]
|
|
|
|
public async Task<RequestEngineResult> RequestMovie([FromBody] MovieRequestViewModel movie)
|
|
|
|
public async Task<RequestEngineResult> RequestMovie([FromBody] MovieRequestViewModel movie)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return await MovieRequestEngine.RequestMovie(movie);
|
|
|
|
var result = await MovieRequestEngine.RequestMovie(movie);
|
|
|
|
|
|
|
|
if (result.Result)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var voteResult = await VoteEngine.UpVote(result.RequestId, RequestType.Movie);
|
|
|
|
|
|
|
|
if (voteResult.IsError)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.LogError("Couldn't automatically add the vote for the movie {0} because {1}", movie.TheMovieDbId, voteResult.ErrorMessage);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -249,7 +265,17 @@ namespace Ombi.Controllers
|
|
|
|
[HttpPost("tv")]
|
|
|
|
[HttpPost("tv")]
|
|
|
|
public async Task<RequestEngineResult> RequestTv([FromBody] TvRequestViewModel tv)
|
|
|
|
public async Task<RequestEngineResult> RequestTv([FromBody] TvRequestViewModel tv)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return await TvRequestEngine.RequestTvShow(tv);
|
|
|
|
var result = await TvRequestEngine.RequestTvShow(tv);
|
|
|
|
|
|
|
|
if (result.Result)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var voteResult = await VoteEngine.UpVote(result.RequestId, RequestType.TvShow);
|
|
|
|
|
|
|
|
if (voteResult.IsError)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.LogError("Couldn't automatically add the vote for the tv {0} because {1}", tv.TvDbId, voteResult.ErrorMessage);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|