From 12fafb24578d39df2eabd2331558b2da961fe8b6 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 8 Feb 2021 19:26:06 -0800 Subject: [PATCH] Fixed: Mark as Failed errors --- frontend/src/Store/Actions/episodeHistoryActions.js | 7 ++----- frontend/src/Store/Actions/historyActions.js | 6 ++---- src/Sonarr.Api.V3/History/HistoryModule.cs | 12 ++++++++++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/frontend/src/Store/Actions/episodeHistoryActions.js b/frontend/src/Store/Actions/episodeHistoryActions.js index 9b1396bea..aeec04991 100644 --- a/frontend/src/Store/Actions/episodeHistoryActions.js +++ b/frontend/src/Store/Actions/episodeHistoryActions.js @@ -86,11 +86,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/frontend/src/Store/Actions/historyActions.js b/frontend/src/Store/Actions/historyActions.js index 3d4a52d13..2d478e009 100644 --- a/frontend/src/Store/Actions/historyActions.js +++ b/frontend/src/Store/Actions/historyActions.js @@ -244,11 +244,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/src/Sonarr.Api.V3/History/HistoryModule.cs b/src/Sonarr.Api.V3/History/HistoryModule.cs index 59e5b5389..f20806d23 100644 --- a/src/Sonarr.Api.V3/History/HistoryModule.cs +++ b/src/Sonarr.Api.V3/History/HistoryModule.cs @@ -1,9 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; -using Nancy; using NzbDrone.Core.Datastore; -using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Download; using NzbDrone.Core.History; @@ -33,6 +31,8 @@ namespace Sonarr.Api.V3.History Get("/since", x => GetHistorySince()); Get("/series", x => GetSeriesHistory()); Post("/failed", x => MarkAsFailed()); + Post(@"/failed/(?[\d]{1,10})", x => MarkAsFailed((int)x.Id)); + } protected HistoryResource MapToResource(EpisodeHistory model, bool includeSeries, bool includeEpisode) @@ -143,10 +143,18 @@ namespace Sonarr.Api.V3.History return _historyService.GetBySeries(seriesId, eventType).Select(h => MapToResource(h, includeSeries, includeEpisode)).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(); } }