From a9792973eef960e8310a611cf1da2d2cada57532 Mon Sep 17 00:00:00 2001 From: nitsua Date: Sun, 14 Feb 2021 10:28:30 -0500 Subject: [PATCH] Fixed: Mark as Failed errors (#5939) Originally by Markus McDowall (cherry picked from commit 12fafb24578d39df2eabd2331558b2da961fe8b6) Co-Authored-By: Mark McDowall Fixes: #5907 Fixes: #5938 --- frontend/src/Store/Actions/historyActions.js | 6 ++---- frontend/src/Store/Actions/movieHistoryActions.js | 7 ++----- src/Radarr.Api.V3/History/HistoryModule.cs | 10 +++++++++- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/frontend/src/Store/Actions/historyActions.js b/frontend/src/Store/Actions/historyActions.js index f9f54fb4f..cdc52de11 100644 --- a/frontend/src/Store/Actions/historyActions.js +++ b/frontend/src/Store/Actions/historyActions.js @@ -232,11 +232,9 @@ export const actionHandlers = handleThunks({ })); const promise = createAjaxRequest({ - url: '/history/failed', + url: `/history/failed/${id}`, method: 'POST', - data: { - id - } + dataType: 'json' }).request; promise.done(() => { diff --git a/frontend/src/Store/Actions/movieHistoryActions.js b/frontend/src/Store/Actions/movieHistoryActions.js index 02c1d7428..06999b169 100644 --- a/frontend/src/Store/Actions/movieHistoryActions.js +++ b/frontend/src/Store/Actions/movieHistoryActions.js @@ -77,11 +77,8 @@ export const actionHandlers = handleThunks({ } = payload; const promise = createAjaxRequest({ - url: '/history/failed', - method: 'POST', - data: { - id: historyId - } + url: `/history/failed/${historyId}`, + method: 'POST' }).request; promise.done(() => { diff --git a/src/Radarr.Api.V3/History/HistoryModule.cs b/src/Radarr.Api.V3/History/HistoryModule.cs index e95338aff..eb41dbe0c 100644 --- a/src/Radarr.Api.V3/History/HistoryModule.cs +++ b/src/Radarr.Api.V3/History/HistoryModule.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using Nancy; using NzbDrone.Core.CustomFormats; using NzbDrone.Core.Datastore; using NzbDrone.Core.DecisionEngine.Specifications; @@ -39,6 +38,7 @@ namespace Radarr.Api.V3.History Get("/since", x => GetHistorySince()); Get("/movie", x => GetMovieHistory()); Post("/failed", x => MarkAsFailed()); + Post(@"/failed/(?[\d]{1,10})", x => MarkAsFailed((int)x.Id)); } protected HistoryResource MapToResource(MovieHistory model, bool includeMovie) @@ -130,10 +130,18 @@ namespace Radarr.Api.V3.History return _historyService.GetByMovieId(movieId, eventType).Select(h => MapToResource(h, includeMovie)).ToList(); } + // v4 TODO: Getting the ID from the form is atypical, consider removing. private object MarkAsFailed() { var id = (int)Request.Form.Id; + + return MarkAsFailed(id); + } + + private object MarkAsFailed(int id) + { _failedDownloadService.MarkAsFailed(id); + return new object(); } }