New: Renamed Blacklist to Blocklist

(cherry picked from commit ead1371846b1f19cd49928052be0128bf7ccd41f)
This commit is contained in:
Robin Dadswell
2021-07-08 23:27:23 +01:00
committed by Qstick
parent 07829a19b8
commit 89319f9833
41 changed files with 427 additions and 319 deletions
@@ -1,43 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using NzbDrone.Core.Blacklisting;
using NzbDrone.Core.Datastore;
using NzbDrone.Http.REST.Attributes;
using Readarr.Http;
using Readarr.Http.Extensions;
namespace Readarr.Api.V1.Blacklist
{
[V1ApiController]
public class BlacklistController : Controller
{
private readonly IBlacklistService _blacklistService;
public BlacklistController(IBlacklistService blacklistService)
{
_blacklistService = blacklistService;
}
[HttpGet]
public PagingResource<BlacklistResource> GetBlacklist()
{
var pagingResource = Request.ReadPagingResourceFromRequest<BlacklistResource>();
var pagingSpec = pagingResource.MapToPagingSpec<BlacklistResource, NzbDrone.Core.Blacklisting.Blacklist>("date", SortDirection.Descending);
return pagingSpec.ApplyToPage(_blacklistService.Paged, BlacklistResourceMapper.MapToResource);
}
[RestDeleteById]
public void DeleteBlacklist(int id)
{
_blacklistService.Delete(id);
}
[HttpDelete("bulk")]
public object Remove([FromBody] BlacklistBulkResource resource)
{
_blacklistService.Delete(resource.Ids);
return new object();
}
}
}
@@ -1,8 +1,8 @@
using System.Collections.Generic;
namespace Readarr.Api.V1.Blacklist
namespace Readarr.Api.V1.Blocklist
{
public class BlacklistBulkResource
public class BlocklistBulkResource
{
public List<int> Ids { get; set; }
}
@@ -0,0 +1,43 @@
using Microsoft.AspNetCore.Mvc;
using NzbDrone.Core.Blocklisting;
using NzbDrone.Core.Datastore;
using NzbDrone.Http.REST.Attributes;
using Readarr.Http;
using Readarr.Http.Extensions;
namespace Readarr.Api.V1.Blocklist
{
[V1ApiController]
public class BlocklistController : Controller
{
private readonly IBlocklistService _blocklistService;
public BlocklistController(IBlocklistService blocklistService)
{
_blocklistService = blocklistService;
}
[HttpGet]
public PagingResource<BlocklistResource> GetBlocklist()
{
var pagingResource = Request.ReadPagingResourceFromRequest<BlocklistResource>();
var pagingSpec = pagingResource.MapToPagingSpec<BlocklistResource, NzbDrone.Core.Blocklisting.Blocklist>("date", SortDirection.Descending);
return pagingSpec.ApplyToPage(_blocklistService.Paged, BlocklistResourceMapper.MapToResource);
}
[RestDeleteById]
public void DeleteBlocklist(int id)
{
_blocklistService.Delete(id);
}
[HttpDelete("bulk")]
public object Remove([FromBody] BlocklistBulkResource resource)
{
_blocklistService.Delete(resource.Ids);
return new object();
}
}
}
@@ -5,9 +5,9 @@ using NzbDrone.Core.Qualities;
using Readarr.Api.V1.Author;
using Readarr.Http.REST;
namespace Readarr.Api.V1.Blacklist
namespace Readarr.Api.V1.Blocklist
{
public class BlacklistResource : RestResource
public class BlocklistResource : RestResource
{
public int AuthorId { get; set; }
public List<int> BookIds { get; set; }
@@ -21,16 +21,16 @@ namespace Readarr.Api.V1.Blacklist
public AuthorResource Author { get; set; }
}
public static class BlacklistResourceMapper
public static class BlocklistResourceMapper
{
public static BlacklistResource MapToResource(this NzbDrone.Core.Blacklisting.Blacklist model)
public static BlocklistResource MapToResource(this NzbDrone.Core.Blocklisting.Blocklist model)
{
if (model == null)
{
return null;
}
return new BlacklistResource
return new BlocklistResource
{
Id = model.Id,
+7 -7
View File
@@ -59,9 +59,9 @@ namespace Readarr.Api.V1.Queue
}
[RestDeleteById]
public void RemoveAction(int id, bool removeFromClient = true, bool blacklist = false, bool skipReDownload = false)
public void RemoveAction(int id, bool removeFromClient = true, bool blocklist = false, bool skipReDownload = false)
{
var trackedDownload = Remove(id, removeFromClient, blacklist, skipReDownload);
var trackedDownload = Remove(id, removeFromClient, blocklist, skipReDownload);
if (trackedDownload != null)
{
@@ -70,13 +70,13 @@ namespace Readarr.Api.V1.Queue
}
[HttpDelete("bulk")]
public object RemoveMany([FromBody] QueueBulkResource resource, [FromQuery] bool removeFromClient = true, [FromQuery] bool blacklist = false, [FromQuery] bool skipReDownload = false)
public object RemoveMany([FromBody] QueueBulkResource resource, [FromQuery] bool removeFromClient = true, [FromQuery] bool blocklist = false, [FromQuery] bool skipReDownload = false)
{
var trackedDownloadIds = new List<string>();
foreach (var id in resource.Ids)
{
var trackedDownload = Remove(id, removeFromClient, blacklist, skipReDownload);
var trackedDownload = Remove(id, removeFromClient, blocklist, skipReDownload);
if (trackedDownload != null)
{
@@ -193,7 +193,7 @@ namespace Readarr.Api.V1.Queue
}
}
private TrackedDownload Remove(int id, bool removeFromClient, bool blacklist, bool skipReDownload)
private TrackedDownload Remove(int id, bool removeFromClient, bool blocklist, bool skipReDownload)
{
var pendingRelease = _pendingReleaseService.FindPendingQueueItem(id);
@@ -223,12 +223,12 @@ namespace Readarr.Api.V1.Queue
downloadClient.RemoveItem(trackedDownload.DownloadItem, true);
}
if (blacklist)
if (blocklist)
{
_failedDownloadService.MarkAsFailed(trackedDownload.DownloadItem.DownloadId, skipReDownload);
}
if (!removeFromClient && !blacklist)
if (!removeFromClient && !blocklist)
{
if (!_ignoredDownloadService.IgnoreDownload(trackedDownload))
{