mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-11 07:46:05 -07:00
Finished #18
This commit is contained in:
parent
8df742abe3
commit
0ac114d987
7 changed files with 214 additions and 17 deletions
|
@ -65,6 +65,7 @@ namespace PlexRequests.UI.Modules
|
|||
HeadphoneApi = hpApi;
|
||||
|
||||
Post["/approve", true] = async (x, ct) => await Approve((int)Request.Form.requestid, (string)Request.Form.qualityId);
|
||||
Post["/deny", true] = async (x, ct) => await DenyRequest((int)Request.Form.requestid, (string)Request.Form.reason);
|
||||
Post["/approveall", true] = async (x, ct) => await ApproveAll();
|
||||
Post["/approveallmovies", true] = async (x, ct) => await ApproveAllMovies();
|
||||
Post["/approvealltvshows", true] = async (x, ct) => await ApproveAllTVShows();
|
||||
|
@ -262,7 +263,7 @@ namespace PlexRequests.UI.Modules
|
|||
{
|
||||
|
||||
var requests = await Service.GetAllAsync();
|
||||
requests = requests.Where(x => x.CanApprove && x.Type == RequestType.Movie);
|
||||
requests = requests.Where(x => x.CanApprove && x.Type == RequestType.Movie);
|
||||
var requestedModels = requests as RequestedModel[] ?? requests.ToArray();
|
||||
if (!requestedModels.Any())
|
||||
{
|
||||
|
@ -491,6 +492,24 @@ namespace PlexRequests.UI.Modules
|
|||
}
|
||||
}
|
||||
|
||||
private async Task<Response> DenyRequest(int requestId, string reason)
|
||||
{
|
||||
// Get the request from the DB
|
||||
var request = await Service.GetAsync(requestId);
|
||||
|
||||
// Deny it
|
||||
request.Denied = true;
|
||||
request.DeniedReason = reason;
|
||||
|
||||
// Update the new value
|
||||
var result = await Service.UpdateRequestAsync(request);
|
||||
|
||||
return result
|
||||
? Response.AsJson(new JsonResponseModel { Result = true, Message = "Request has been denied" })
|
||||
: Response.AsJson(new JsonResponseModel { Result = false, Message = "An error happened, could not update the DB" });
|
||||
|
||||
}
|
||||
|
||||
private bool SendMovie(CouchPotatoSettings settings, RequestedModel r, ICouchPotatoApi cp)
|
||||
{
|
||||
Log.Info("Adding movie to CP : {0}", r.Title);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue