Fixed: Mark as Failed errors

This commit is contained in:
Mark McDowall 2021-02-08 19:26:06 -08:00
parent 795bc91d25
commit 12fafb2457
3 changed files with 14 additions and 11 deletions

View File

@ -86,11 +86,8 @@ export const actionHandlers = handleThunks({
} = payload; } = payload;
const promise = createAjaxRequest({ const promise = createAjaxRequest({
url: '/history/failed', url: `/history/failed/${historyId}`,
method: 'POST', method: 'POST'
data: {
id: historyId
}
}).request; }).request;
promise.done(() => { promise.done(() => {

View File

@ -244,11 +244,9 @@ export const actionHandlers = handleThunks({
})); }));
const promise = createAjaxRequest({ const promise = createAjaxRequest({
url: '/history/failed', url: `/history/failed/${id}`,
method: 'POST', method: 'POST',
data: { dataType: 'json'
id
}
}).request; }).request;
promise.done(() => { promise.done(() => {

View File

@ -1,9 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Nancy;
using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.Download; using NzbDrone.Core.Download;
using NzbDrone.Core.History; using NzbDrone.Core.History;
@ -33,6 +31,8 @@ namespace Sonarr.Api.V3.History
Get("/since", x => GetHistorySince()); Get("/since", x => GetHistorySince());
Get("/series", x => GetSeriesHistory()); Get("/series", x => GetSeriesHistory());
Post("/failed", x => MarkAsFailed()); Post("/failed", x => MarkAsFailed());
Post(@"/failed/(?<id>[\d]{1,10})", x => MarkAsFailed((int)x.Id));
} }
protected HistoryResource MapToResource(EpisodeHistory model, bool includeSeries, bool includeEpisode) 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(); 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() private object MarkAsFailed()
{ {
var id = (int)Request.Form.Id; var id = (int)Request.Form.Id;
return MarkAsFailed(id);
}
private object MarkAsFailed(int id)
{
_failedDownloadService.MarkAsFailed(id); _failedDownloadService.MarkAsFailed(id);
return new object(); return new object();
} }
} }