mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 02:37:08 -07:00
New: Renamed Blacklist to Blocklist
This commit is contained in:
parent
0d7b6f8a4f
commit
8573065a4e
38 changed files with 360 additions and 332 deletions
|
@ -1,43 +0,0 @@
|
|||
using Lidarr.Http;
|
||||
using Lidarr.Http.Extensions;
|
||||
using Lidarr.Http.REST.Attributes;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NzbDrone.Core.Blacklisting;
|
||||
using NzbDrone.Core.Datastore;
|
||||
|
||||
namespace Lidarr.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 Lidarr.Api.V1.Blacklist
|
||||
namespace Lidarr.Api.V1.Blocklist
|
||||
{
|
||||
public class BlacklistBulkResource
|
||||
public class BlocklistBulkResource
|
||||
{
|
||||
public List<int> Ids { get; set; }
|
||||
}
|
43
src/Lidarr.Api.V1/Blocklist/BlocklistController.cs
Normal file
43
src/Lidarr.Api.V1/Blocklist/BlocklistController.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
using Lidarr.Http;
|
||||
using Lidarr.Http.Extensions;
|
||||
using Lidarr.Http.REST.Attributes;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NzbDrone.Core.Blocklisting;
|
||||
using NzbDrone.Core.Datastore;
|
||||
|
||||
namespace Lidarr.Api.V1.Blocklist
|
||||
{
|
||||
[V1ApiController]
|
||||
public class BlocklistController : Controller
|
||||
{
|
||||
private readonly IBlocklistService _blocklistService;
|
||||
|
||||
public BlocklistController(IBlocklistService blocklistService)
|
||||
{
|
||||
_blocklistService = blocklistService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public PagingResource<BlocklistResource> GetBlacklist()
|
||||
{
|
||||
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 Lidarr.Http.REST;
|
|||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Qualities;
|
||||
|
||||
namespace Lidarr.Api.V1.Blacklist
|
||||
namespace Lidarr.Api.V1.Blocklist
|
||||
{
|
||||
public class BlacklistResource : RestResource
|
||||
public class BlocklistResource : RestResource
|
||||
{
|
||||
public int ArtistId { get; set; }
|
||||
public List<int> AlbumIds { get; set; }
|
||||
|
@ -21,16 +21,16 @@ namespace Lidarr.Api.V1.Blacklist
|
|||
public ArtistResource Artist { 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,
|
||||
|
|
@ -791,10 +791,10 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/blacklist": {
|
||||
"/api/v1/blocklist": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Blacklist"
|
||||
"Blocklist"
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
|
@ -802,17 +802,17 @@
|
|||
"content": {
|
||||
"text/plain": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/BlacklistResourcePagingResource"
|
||||
"$ref": "#/components/schemas/BlocklistResourcePagingResource"
|
||||
}
|
||||
},
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/BlacklistResourcePagingResource"
|
||||
"$ref": "#/components/schemas/BlocklistResourcePagingResource"
|
||||
}
|
||||
},
|
||||
"text/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/BlacklistResourcePagingResource"
|
||||
"$ref": "#/components/schemas/BlocklistResourcePagingResource"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -820,10 +820,10 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/blacklist/{id}": {
|
||||
"/api/v1/blocklist/{id}": {
|
||||
"delete": {
|
||||
"tags": [
|
||||
"Blacklist"
|
||||
"Blocklist"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
|
@ -843,26 +843,26 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/blacklist/bulk": {
|
||||
"/api/v1/blocklist/bulk": {
|
||||
"delete": {
|
||||
"tags": [
|
||||
"Blacklist"
|
||||
"Blocklist"
|
||||
],
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/BlacklistBulkResource"
|
||||
"$ref": "#/components/schemas/BlocklistBulkResource"
|
||||
}
|
||||
},
|
||||
"text/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/BlacklistBulkResource"
|
||||
"$ref": "#/components/schemas/BlocklistBulkResource"
|
||||
}
|
||||
},
|
||||
"application/*+json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/BlacklistBulkResource"
|
||||
"$ref": "#/components/schemas/BlocklistBulkResource"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5905,7 +5905,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"name": "blacklist",
|
||||
"name": "blocklist",
|
||||
"in": "query",
|
||||
"schema": {
|
||||
"type": "boolean",
|
||||
|
@ -5943,7 +5943,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"name": "blacklist",
|
||||
"name": "blocklist",
|
||||
"in": "query",
|
||||
"schema": {
|
||||
"type": "boolean",
|
||||
|
@ -9421,7 +9421,7 @@
|
|||
],
|
||||
"type": "string"
|
||||
},
|
||||
"BlacklistBulkResource": {
|
||||
"BlocklistBulkResource": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ids": {
|
||||
|
@ -9435,7 +9435,7 @@
|
|||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"BlacklistResource": {
|
||||
"BlocklistResource": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
|
@ -9482,7 +9482,7 @@
|
|||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"BlacklistResourcePagingResource": {
|
||||
"BlocklistResourcePagingResource": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"page": {
|
||||
|
@ -9514,7 +9514,7 @@
|
|||
"records": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/BlacklistResource"
|
||||
"$ref": "#/components/schemas/BlocklistResource"
|
||||
},
|
||||
"nullable": true
|
||||
}
|
||||
|
@ -13106,4 +13106,4 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace NzbDrone.Automation.Test
|
|||
|
||||
_page.Find(By.LinkText("Queue")).Should().NotBeNull();
|
||||
_page.Find(By.LinkText("History")).Should().NotBeNull();
|
||||
_page.Find(By.LinkText("Blacklist")).Should().NotBeNull();
|
||||
_page.Find(By.LinkText("Blocklist")).Should().NotBeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -3,21 +3,21 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Blacklisting;
|
||||
using NzbDrone.Core.Blocklisting;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.Blacklisting
|
||||
namespace NzbDrone.Core.Test.Blocklisting
|
||||
{
|
||||
[TestFixture]
|
||||
public class BlacklistRepositoryFixture : DbTest<BlacklistRepository, Blacklist>
|
||||
public class BlocklistRepositoryFixture : DbTest<BlocklistRepository, Blocklist>
|
||||
{
|
||||
private Blacklist _blacklist;
|
||||
private Blocklist _blocklist;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_blacklist = new Blacklist
|
||||
_blocklist = new Blocklist
|
||||
{
|
||||
ArtistId = 12345,
|
||||
AlbumIds = new List<int> { 1 },
|
||||
|
@ -30,24 +30,24 @@ namespace NzbDrone.Core.Test.Blacklisting
|
|||
[Test]
|
||||
public void should_be_able_to_write_to_database()
|
||||
{
|
||||
Subject.Insert(_blacklist);
|
||||
Subject.Insert(_blocklist);
|
||||
Subject.All().Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_should_have_album_ids()
|
||||
{
|
||||
Subject.Insert(_blacklist);
|
||||
Subject.Insert(_blocklist);
|
||||
|
||||
Subject.All().First().AlbumIds.Should().Contain(_blacklist.AlbumIds);
|
||||
Subject.All().First().AlbumIds.Should().Contain(_blocklist.AlbumIds);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_check_for_blacklisted_title_case_insensative()
|
||||
public void should_check_for_blocklisted_title_case_insensative()
|
||||
{
|
||||
Subject.Insert(_blacklist);
|
||||
Subject.Insert(_blocklist);
|
||||
|
||||
Subject.BlacklistedByTitle(_blacklist.ArtistId, _blacklist.SourceTitle.ToUpperInvariant()).Should().HaveCount(1);
|
||||
Subject.BlocklistedByTitle(_blocklist.ArtistId, _blocklist.SourceTitle.ToUpperInvariant()).Should().HaveCount(1);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,15 +2,15 @@
|
|||
using System.Collections.Generic;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Blacklisting;
|
||||
using NzbDrone.Core.Blocklisting;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.Blacklisting
|
||||
namespace NzbDrone.Core.Test.Blocklisting
|
||||
{
|
||||
[TestFixture]
|
||||
public class BlacklistServiceFixture : CoreTest<BlacklistService>
|
||||
public class BlocklistServiceFixture : CoreTest<BlocklistService>
|
||||
{
|
||||
private DownloadFailedEvent _event;
|
||||
|
||||
|
@ -39,8 +39,8 @@ namespace NzbDrone.Core.Test.Blacklisting
|
|||
{
|
||||
Subject.Handle(_event);
|
||||
|
||||
Mocker.GetMock<IBlacklistRepository>()
|
||||
.Verify(v => v.Insert(It.Is<Blacklist>(b => b.AlbumIds == _event.AlbumIds)), Times.Once());
|
||||
Mocker.GetMock<IBlocklistRepository>()
|
||||
.Verify(v => v.Insert(It.Is<Blocklist>(b => b.AlbumIds == _event.AlbumIds)), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -51,8 +51,8 @@ namespace NzbDrone.Core.Test.Blacklisting
|
|||
_event.Data.Remove("size");
|
||||
_event.Data.Remove("protocol");
|
||||
|
||||
Mocker.GetMock<IBlacklistRepository>()
|
||||
.Verify(v => v.Insert(It.Is<Blacklist>(b => b.AlbumIds == _event.AlbumIds)), Times.Once());
|
||||
Mocker.GetMock<IBlocklistRepository>()
|
||||
.Verify(v => v.Insert(It.Is<Blocklist>(b => b.AlbumIds == _event.AlbumIds)), Times.Once());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Blacklisting;
|
||||
using NzbDrone.Core.Blocklisting;
|
||||
using NzbDrone.Core.Housekeeping.Housekeepers;
|
||||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Qualities;
|
||||
|
@ -11,35 +11,35 @@ using NzbDrone.Core.Test.Framework;
|
|||
namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
|
||||
{
|
||||
[TestFixture]
|
||||
public class CleanupOrphanedBlacklistFixture : DbTest<CleanupOrphanedBlacklist, Blacklist>
|
||||
public class CleanupOrphanedBlocklistFixture : DbTest<CleanupOrphanedBlocklist, Blocklist>
|
||||
{
|
||||
[Test]
|
||||
public void should_delete_orphaned_blacklist_items()
|
||||
public void should_delete_orphaned_blocklist_items()
|
||||
{
|
||||
var blacklist = Builder<Blacklist>.CreateNew()
|
||||
var blocklist = Builder<Blocklist>.CreateNew()
|
||||
.With(h => h.AlbumIds = new List<int>())
|
||||
.With(h => h.Quality = new QualityModel())
|
||||
.BuildNew();
|
||||
|
||||
Db.Insert(blacklist);
|
||||
Db.Insert(blocklist);
|
||||
Subject.Clean();
|
||||
AllStoredModels.Should().BeEmpty();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_delete_unorphaned_blacklist_items()
|
||||
public void should_not_delete_unorphaned_blocklist_items()
|
||||
{
|
||||
var artist = Builder<Artist>.CreateNew().BuildNew();
|
||||
|
||||
Db.Insert(artist);
|
||||
|
||||
var blacklist = Builder<Blacklist>.CreateNew()
|
||||
var blocklist = Builder<Blocklist>.CreateNew()
|
||||
.With(h => h.AlbumIds = new List<int>())
|
||||
.With(h => h.Quality = new QualityModel())
|
||||
.With(b => b.ArtistId = artist.Id)
|
||||
.BuildNew();
|
||||
|
||||
Db.Insert(blacklist);
|
||||
Db.Insert(blocklist);
|
||||
|
||||
Subject.Clean();
|
||||
AllStoredModels.Should().HaveCount(1);
|
||||
|
|
|
@ -47,25 +47,25 @@ namespace NzbDrone.Core.Test.MetadataSource
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void should_prefer_blacklist_over_the_blacklist_when_searching_for_blacklist()
|
||||
public void should_prefer_blocklist_over_the_blocklist_when_searching_for_blocklist()
|
||||
{
|
||||
WithSeries("The Blacklist");
|
||||
WithSeries("Blacklist");
|
||||
WithSeries("The Blocklist");
|
||||
WithSeries("Blocklist");
|
||||
|
||||
_artist.Sort(new SearchArtistComparer("blacklist"));
|
||||
_artist.Sort(new SearchArtistComparer("blocklist"));
|
||||
|
||||
_artist.First().Name.Should().Be("Blacklist");
|
||||
_artist.First().Name.Should().Be("Blocklist");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_prefer_the_blacklist_over_blacklist_when_searching_for_the_blacklist()
|
||||
public void should_prefer_the_blocklist_over_blocklist_when_searching_for_the_blocklist()
|
||||
{
|
||||
WithSeries("Blacklist");
|
||||
WithSeries("The Blacklist");
|
||||
WithSeries("Blocklist");
|
||||
WithSeries("The Blocklist");
|
||||
|
||||
_artist.Sort(new SearchArtistComparer("the blacklist"));
|
||||
_artist.Sort(new SearchArtistComparer("the blocklist"));
|
||||
|
||||
_artist.First().Name.Should().Be("The Blacklist");
|
||||
_artist.First().Name.Should().Be("The Blocklist");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@ using NzbDrone.Core.Indexers;
|
|||
using NzbDrone.Core.Music;
|
||||
using NzbDrone.Core.Qualities;
|
||||
|
||||
namespace NzbDrone.Core.Blacklisting
|
||||
namespace NzbDrone.Core.Blocklisting
|
||||
{
|
||||
public class Blacklist : ModelBase
|
||||
public class Blocklist : ModelBase
|
||||
{
|
||||
public int ArtistId { get; set; }
|
||||
public Artist Artist { get; set; }
|
|
@ -3,34 +3,34 @@ using NzbDrone.Core.Datastore;
|
|||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Music;
|
||||
|
||||
namespace NzbDrone.Core.Blacklisting
|
||||
namespace NzbDrone.Core.Blocklisting
|
||||
{
|
||||
public interface IBlacklistRepository : IBasicRepository<Blacklist>
|
||||
public interface IBlocklistRepository : IBasicRepository<Blocklist>
|
||||
{
|
||||
List<Blacklist> BlacklistedByTitle(int artistId, string sourceTitle);
|
||||
List<Blacklist> BlacklistedByTorrentInfoHash(int artistId, string torrentInfoHash);
|
||||
List<Blacklist> BlacklistedByArtists(List<int> artistIds);
|
||||
List<Blocklist> BlocklistedByTitle(int artistId, string sourceTitle);
|
||||
List<Blocklist> BlocklistedByTorrentInfoHash(int artistId, string torrentInfoHash);
|
||||
List<Blocklist> BlocklistedByArtists(List<int> artistIds);
|
||||
void DeleteForArtists(List<int> artistIds);
|
||||
}
|
||||
|
||||
public class BlacklistRepository : BasicRepository<Blacklist>, IBlacklistRepository
|
||||
public class BlocklistRepository : BasicRepository<Blocklist>, IBlocklistRepository
|
||||
{
|
||||
public BlacklistRepository(IMainDatabase database, IEventAggregator eventAggregator)
|
||||
public BlocklistRepository(IMainDatabase database, IEventAggregator eventAggregator)
|
||||
: base(database, eventAggregator)
|
||||
{
|
||||
}
|
||||
|
||||
public List<Blacklist> BlacklistedByTitle(int artistId, string sourceTitle)
|
||||
public List<Blocklist> BlocklistedByTitle(int artistId, string sourceTitle)
|
||||
{
|
||||
return Query(e => e.ArtistId == artistId && e.SourceTitle.Contains(sourceTitle));
|
||||
}
|
||||
|
||||
public List<Blacklist> BlacklistedByTorrentInfoHash(int artistId, string torrentInfoHash)
|
||||
public List<Blocklist> BlocklistedByTorrentInfoHash(int artistId, string torrentInfoHash)
|
||||
{
|
||||
return Query(e => e.ArtistId == artistId && e.TorrentInfoHash.Contains(torrentInfoHash));
|
||||
}
|
||||
|
||||
public List<Blacklist> BlacklistedByArtists(List<int> artistIds)
|
||||
public List<Blocklist> BlocklistedByArtists(List<int> artistIds)
|
||||
{
|
||||
return Query(x => artistIds.Contains(x.ArtistId));
|
||||
}
|
||||
|
@ -40,8 +40,8 @@ namespace NzbDrone.Core.Blacklisting
|
|||
Delete(x => artistIds.Contains(x.ArtistId));
|
||||
}
|
||||
|
||||
protected override SqlBuilder PagedBuilder() => new SqlBuilder().Join<Blacklist, Artist>((b, m) => b.ArtistId == m.Id);
|
||||
protected override IEnumerable<Blacklist> PagedQuery(SqlBuilder builder) => _database.QueryJoined<Blacklist, Artist>(builder, (bl, artist) =>
|
||||
protected override SqlBuilder PagedBuilder() => new SqlBuilder().Join<Blocklist, Artist>((b, m) => b.ArtistId == m.Id);
|
||||
protected override IEnumerable<Blocklist> PagedQuery(SqlBuilder builder) => _database.QueryJoined<Blocklist, Artist>(builder, (bl, artist) =>
|
||||
{
|
||||
bl.Artist = artist;
|
||||
return bl;
|
|
@ -10,32 +10,32 @@ using NzbDrone.Core.Messaging.Events;
|
|||
using NzbDrone.Core.Music.Events;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.Blacklisting
|
||||
namespace NzbDrone.Core.Blocklisting
|
||||
{
|
||||
public interface IBlacklistService
|
||||
public interface IBlocklistService
|
||||
{
|
||||
bool Blacklisted(int artistId, ReleaseInfo release);
|
||||
PagingSpec<Blacklist> Paged(PagingSpec<Blacklist> pagingSpec);
|
||||
bool Blocklisted(int artistId, ReleaseInfo release);
|
||||
PagingSpec<Blocklist> Paged(PagingSpec<Blocklist> pagingSpec);
|
||||
void Delete(int id);
|
||||
void Delete(List<int> ids);
|
||||
}
|
||||
|
||||
public class BlacklistService : IBlacklistService,
|
||||
public class BlocklistService : IBlocklistService,
|
||||
|
||||
IExecute<ClearBlacklistCommand>,
|
||||
IExecute<ClearBlocklistCommand>,
|
||||
IHandle<DownloadFailedEvent>,
|
||||
IHandleAsync<ArtistsDeletedEvent>
|
||||
{
|
||||
private readonly IBlacklistRepository _blacklistRepository;
|
||||
private readonly IBlocklistRepository _blocklistRepository;
|
||||
|
||||
public BlacklistService(IBlacklistRepository blacklistRepository)
|
||||
public BlocklistService(IBlocklistRepository blocklistRepository)
|
||||
{
|
||||
_blacklistRepository = blacklistRepository;
|
||||
_blocklistRepository = blocklistRepository;
|
||||
}
|
||||
|
||||
public bool Blacklisted(int artistId, ReleaseInfo release)
|
||||
public bool Blocklisted(int artistId, ReleaseInfo release)
|
||||
{
|
||||
var blacklistedByTitle = _blacklistRepository.BlacklistedByTitle(artistId, release.Title);
|
||||
var blocklistedByTitle = _blocklistRepository.BlocklistedByTitle(artistId, release.Title);
|
||||
|
||||
if (release.DownloadProtocol == DownloadProtocol.Torrent)
|
||||
{
|
||||
|
@ -48,35 +48,35 @@ namespace NzbDrone.Core.Blacklisting
|
|||
|
||||
if (torrentInfo.InfoHash.IsNullOrWhiteSpace())
|
||||
{
|
||||
return blacklistedByTitle.Where(b => b.Protocol == DownloadProtocol.Torrent)
|
||||
return blocklistedByTitle.Where(b => b.Protocol == DownloadProtocol.Torrent)
|
||||
.Any(b => SameTorrent(b, torrentInfo));
|
||||
}
|
||||
|
||||
var blacklistedByTorrentInfohash = _blacklistRepository.BlacklistedByTorrentInfoHash(artistId, torrentInfo.InfoHash);
|
||||
var blocklistedByTorrentInfohash = _blocklistRepository.BlocklistedByTorrentInfoHash(artistId, torrentInfo.InfoHash);
|
||||
|
||||
return blacklistedByTorrentInfohash.Any(b => SameTorrent(b, torrentInfo));
|
||||
return blocklistedByTorrentInfohash.Any(b => SameTorrent(b, torrentInfo));
|
||||
}
|
||||
|
||||
return blacklistedByTitle.Where(b => b.Protocol == DownloadProtocol.Usenet)
|
||||
return blocklistedByTitle.Where(b => b.Protocol == DownloadProtocol.Usenet)
|
||||
.Any(b => SameNzb(b, release));
|
||||
}
|
||||
|
||||
public PagingSpec<Blacklist> Paged(PagingSpec<Blacklist> pagingSpec)
|
||||
public PagingSpec<Blocklist> Paged(PagingSpec<Blocklist> pagingSpec)
|
||||
{
|
||||
return _blacklistRepository.GetPaged(pagingSpec);
|
||||
return _blocklistRepository.GetPaged(pagingSpec);
|
||||
}
|
||||
|
||||
public void Delete(int id)
|
||||
{
|
||||
_blacklistRepository.Delete(id);
|
||||
_blocklistRepository.Delete(id);
|
||||
}
|
||||
|
||||
public void Delete(List<int> ids)
|
||||
{
|
||||
_blacklistRepository.DeleteMany(ids);
|
||||
_blocklistRepository.DeleteMany(ids);
|
||||
}
|
||||
|
||||
private bool SameNzb(Blacklist item, ReleaseInfo release)
|
||||
private bool SameNzb(Blocklist item, ReleaseInfo release)
|
||||
{
|
||||
if (item.PublishedDate == release.PublishDate)
|
||||
{
|
||||
|
@ -93,7 +93,7 @@ namespace NzbDrone.Core.Blacklisting
|
|||
return false;
|
||||
}
|
||||
|
||||
private bool SameTorrent(Blacklist item, TorrentInfo release)
|
||||
private bool SameTorrent(Blocklist item, TorrentInfo release)
|
||||
{
|
||||
if (release.InfoHash.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
|
@ -103,7 +103,7 @@ namespace NzbDrone.Core.Blacklisting
|
|||
return item.Indexer.Equals(release.Indexer, StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
private bool HasSameIndexer(Blacklist item, string indexer)
|
||||
private bool HasSameIndexer(Blocklist item, string indexer)
|
||||
{
|
||||
if (item.Indexer.IsNullOrWhiteSpace())
|
||||
{
|
||||
|
@ -113,7 +113,7 @@ namespace NzbDrone.Core.Blacklisting
|
|||
return item.Indexer.Equals(indexer, StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
private bool HasSamePublishedDate(Blacklist item, DateTime publishedDate)
|
||||
private bool HasSamePublishedDate(Blocklist item, DateTime publishedDate)
|
||||
{
|
||||
if (!item.PublishedDate.HasValue)
|
||||
{
|
||||
|
@ -124,7 +124,7 @@ namespace NzbDrone.Core.Blacklisting
|
|||
item.PublishedDate.Value.AddMinutes(2) >= publishedDate;
|
||||
}
|
||||
|
||||
private bool HasSameSize(Blacklist item, long size)
|
||||
private bool HasSameSize(Blocklist item, long size)
|
||||
{
|
||||
if (!item.Size.HasValue)
|
||||
{
|
||||
|
@ -136,14 +136,14 @@ namespace NzbDrone.Core.Blacklisting
|
|||
return difference <= 2.Megabytes();
|
||||
}
|
||||
|
||||
public void Execute(ClearBlacklistCommand message)
|
||||
public void Execute(ClearBlocklistCommand message)
|
||||
{
|
||||
_blacklistRepository.Purge();
|
||||
_blocklistRepository.Purge();
|
||||
}
|
||||
|
||||
public void Handle(DownloadFailedEvent message)
|
||||
{
|
||||
var blacklist = new Blacklist
|
||||
var blocklist = new Blocklist
|
||||
{
|
||||
ArtistId = message.ArtistId,
|
||||
AlbumIds = message.AlbumIds,
|
||||
|
@ -158,12 +158,12 @@ namespace NzbDrone.Core.Blacklisting
|
|||
TorrentInfoHash = message.Data.GetValueOrDefault("torrentInfoHash")
|
||||
};
|
||||
|
||||
_blacklistRepository.Insert(blacklist);
|
||||
_blocklistRepository.Insert(blocklist);
|
||||
}
|
||||
|
||||
public void HandleAsync(ArtistsDeletedEvent message)
|
||||
{
|
||||
_blacklistRepository.DeleteForArtists(message.Artists.Select(x => x.Id).ToList());
|
||||
_blocklistRepository.DeleteForArtists(message.Artists.Select(x => x.Id).ToList());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
using NzbDrone.Core.Messaging.Commands;
|
||||
|
||||
namespace NzbDrone.Core.Blacklisting
|
||||
namespace NzbDrone.Core.Blocklisting
|
||||
{
|
||||
public class ClearBlacklistCommand : Command
|
||||
public class ClearBlocklistCommand : Command
|
||||
{
|
||||
public override bool SendUpdatesToClient => true;
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
using FluentMigrator;
|
||||
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migration
|
||||
{
|
||||
[Migration(050)]
|
||||
public class rename_blacklist_to_blocklist : NzbDroneMigrationBase
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Rename.Table("Blacklist").To("Blocklist");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||
using Dapper;
|
||||
using NzbDrone.Common.Reflection;
|
||||
using NzbDrone.Core.Authentication;
|
||||
using NzbDrone.Core.Blacklisting;
|
||||
using NzbDrone.Core.Blocklisting;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.CustomFilters;
|
||||
using NzbDrone.Core.Datastore.Converters;
|
||||
|
@ -165,7 +165,7 @@ namespace NzbDrone.Core.Datastore
|
|||
Mapper.Entity<Log>("Logs").RegisterModel();
|
||||
Mapper.Entity<NamingConfig>("NamingConfig").RegisterModel();
|
||||
|
||||
Mapper.Entity<Blacklist>("Blacklist").RegisterModel();
|
||||
Mapper.Entity<Blocklist>("Blocklist").RegisterModel();
|
||||
Mapper.Entity<MetadataFile>("MetadataFiles").RegisterModel();
|
||||
Mapper.Entity<LyricFile>("LyricFiles").RegisterModel();
|
||||
Mapper.Entity<OtherExtraFile>("ExtraFiles").RegisterModel();
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
using NLog;
|
||||
using NzbDrone.Core.Blacklisting;
|
||||
using NzbDrone.Core.Blocklisting;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.DecisionEngine.Specifications
|
||||
{
|
||||
public class BlacklistSpecification : IDecisionEngineSpecification
|
||||
public class BlocklistSpecification : IDecisionEngineSpecification
|
||||
{
|
||||
private readonly IBlacklistService _blacklistService;
|
||||
private readonly IBlocklistService _blocklistService;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public BlacklistSpecification(IBlacklistService blacklistService, Logger logger)
|
||||
public BlocklistSpecification(IBlocklistService blocklistService, Logger logger)
|
||||
{
|
||||
_blacklistService = blacklistService;
|
||||
_blocklistService = blocklistService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
|
@ -21,10 +21,10 @@ namespace NzbDrone.Core.DecisionEngine.Specifications
|
|||
|
||||
public Decision IsSatisfiedBy(RemoteAlbum subject, SearchCriteriaBase searchCriteria)
|
||||
{
|
||||
if (_blacklistService.Blacklisted(subject.Artist.Id, subject.Release))
|
||||
if (_blocklistService.Blocklisted(subject.Artist.Id, subject.Release))
|
||||
{
|
||||
_logger.Debug("{0} is blacklisted, rejecting.", subject.Release.Title);
|
||||
return Decision.Reject("Release is blacklisted");
|
||||
_logger.Debug("{0} is blocklisted, rejecting.", subject.Release.Title);
|
||||
return Decision.Reject("Release is blocklisted");
|
||||
}
|
||||
|
||||
return Decision.Accept();
|
|
@ -3,11 +3,11 @@ using NzbDrone.Core.Datastore;
|
|||
|
||||
namespace NzbDrone.Core.Housekeeping.Housekeepers
|
||||
{
|
||||
public class CleanupOrphanedBlacklist : IHousekeepingTask
|
||||
public class CleanupOrphanedBlocklist : IHousekeepingTask
|
||||
{
|
||||
private readonly IMainDatabase _database;
|
||||
|
||||
public CleanupOrphanedBlacklist(IMainDatabase database)
|
||||
public CleanupOrphanedBlocklist(IMainDatabase database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
@ -16,11 +16,11 @@ namespace NzbDrone.Core.Housekeeping.Housekeepers
|
|||
{
|
||||
using (var mapper = _database.OpenConnection())
|
||||
{
|
||||
mapper.Execute(@"DELETE FROM Blacklist
|
||||
mapper.Execute(@"DELETE FROM Blocklist
|
||||
WHERE Id IN (
|
||||
SELECT Blacklist.Id FROM Blacklist
|
||||
SELECT Blocklist.Id FROM Blocklist
|
||||
LEFT OUTER JOIN Artists
|
||||
ON Blacklist.ArtistId = Artists.Id
|
||||
ON Blocklist.ArtistId = Artists.Id
|
||||
WHERE Artists.Id IS NULL)");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,33 @@
|
|||
using FluentAssertions;
|
||||
using Lidarr.Api.V1.Artist;
|
||||
using Lidarr.Api.V1.Blacklist;
|
||||
using Lidarr.Api.V1.Blocklist;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NzbDrone.Integration.Test.ApiTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class BlacklistFixture : IntegrationTest
|
||||
public class BlocklistFixture : IntegrationTest
|
||||
{
|
||||
private ArtistResource _artist;
|
||||
|
||||
[Test]
|
||||
[Ignore("Adding to blacklist not supported")]
|
||||
public void should_be_able_to_add_to_blacklist()
|
||||
[Ignore("Adding to blocklist not supported")]
|
||||
public void should_be_able_to_add_to_blocklist()
|
||||
{
|
||||
_artist = EnsureArtist("8ac6cc32-8ddf-43b1-9ac4-4b04f9053176", "Alien Ant Farm");
|
||||
|
||||
Blacklist.Post(new BlacklistResource
|
||||
Blocklist.Post(new BlocklistResource
|
||||
{
|
||||
ArtistId = _artist.Id,
|
||||
SourceTitle = "Blacklist - Album 1 [2015 FLAC]"
|
||||
SourceTitle = "Blocklist - Album 1 [2015 FLAC]"
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Ignore("Adding to blacklist not supported")]
|
||||
public void should_be_able_to_get_all_blacklisted()
|
||||
[Ignore("Adding to blocklist not supported")]
|
||||
public void should_be_able_to_get_all_blocklisted()
|
||||
{
|
||||
var result = Blacklist.GetPaged(0, 1000, "date", "desc");
|
||||
var result = Blocklist.GetPaged(0, 1000, "date", "desc");
|
||||
|
||||
result.Should().NotBeNull();
|
||||
result.TotalRecords.Should().Be(1);
|
||||
|
@ -35,12 +35,12 @@ namespace NzbDrone.Integration.Test.ApiTests
|
|||
}
|
||||
|
||||
[Test]
|
||||
[Ignore("Adding to blacklist not supported")]
|
||||
public void should_be_able_to_remove_from_blacklist()
|
||||
[Ignore("Adding to blocklist not supported")]
|
||||
public void should_be_able_to_remove_from_blocklist()
|
||||
{
|
||||
Blacklist.Delete(1);
|
||||
Blocklist.Delete(1);
|
||||
|
||||
var result = Blacklist.GetPaged(0, 1000, "date", "desc");
|
||||
var result = Blocklist.GetPaged(0, 1000, "date", "desc");
|
||||
|
||||
result.Should().NotBeNull();
|
||||
result.TotalRecords.Should().Be(0);
|
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
|||
using FluentAssertions;
|
||||
using Lidarr.Api.V1.Albums;
|
||||
using Lidarr.Api.V1.Artist;
|
||||
using Lidarr.Api.V1.Blacklist;
|
||||
using Lidarr.Api.V1.Blocklist;
|
||||
using Lidarr.Api.V1.Config;
|
||||
using Lidarr.Api.V1.DownloadClient;
|
||||
using Lidarr.Api.V1.History;
|
||||
|
@ -37,7 +37,7 @@ namespace NzbDrone.Integration.Test
|
|||
{
|
||||
protected RestClient RestClient { get; private set; }
|
||||
|
||||
public ClientBase<BlacklistResource> Blacklist;
|
||||
public ClientBase<BlocklistResource> Blocklist;
|
||||
public CommandClient Commands;
|
||||
public ClientBase<TaskResource> Tasks;
|
||||
public DownloadClientClient DownloadClients;
|
||||
|
@ -103,7 +103,7 @@ namespace NzbDrone.Integration.Test
|
|||
RestClient.AddDefaultHeader("X-Api-Key", ApiKey);
|
||||
RestClient.UseSystemTextJson();
|
||||
|
||||
Blacklist = new ClientBase<BlacklistResource>(RestClient, ApiKey);
|
||||
Blocklist = new ClientBase<BlocklistResource>(RestClient, ApiKey);
|
||||
Commands = new CommandClient(RestClient, ApiKey);
|
||||
Tasks = new ClientBase<TaskResource>(RestClient, ApiKey, "system/task");
|
||||
DownloadClients = new DownloadClientClient(RestClient, ApiKey);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue