mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-11 07:37:10 -07:00
Fixed: Adding indexers from presets
(cherry picked from commit 5cc0331c75993ecd79e17b2da1c2d5dcd08f6b0f)
This commit is contained in:
parent
b0ea6550d7
commit
9ba87ceee3
9 changed files with 21 additions and 16 deletions
|
@ -3,7 +3,7 @@ using NzbDrone.Core.Indexers;
|
|||
|
||||
namespace Lidarr.Api.V1.DownloadClient
|
||||
{
|
||||
public class DownloadClientResource : ProviderResource
|
||||
public class DownloadClientResource : ProviderResource<DownloadClientResource>
|
||||
{
|
||||
public bool Enable { get; set; }
|
||||
public DownloadProtocol Protocol { get; set; }
|
||||
|
|
|
@ -2,7 +2,7 @@ using NzbDrone.Core.ImportLists;
|
|||
|
||||
namespace Lidarr.Api.V1.ImportLists
|
||||
{
|
||||
public class ImportListResource : ProviderResource
|
||||
public class ImportListResource : ProviderResource<ImportListResource>
|
||||
{
|
||||
public bool EnableAutomaticAdd { get; set; }
|
||||
public ImportListMonitorType ShouldMonitor { get; set; }
|
||||
|
|
|
@ -2,7 +2,7 @@ using NzbDrone.Core.Indexers;
|
|||
|
||||
namespace Lidarr.Api.V1.Indexers
|
||||
{
|
||||
public class IndexerResource : ProviderResource
|
||||
public class IndexerResource : ProviderResource<IndexerResource>
|
||||
{
|
||||
public bool EnableRss { get; set; }
|
||||
public bool EnableAutomaticSearch { get; set; }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Lidarr.Api.V1.Metadata
|
||||
{
|
||||
public class MetadataResource : ProviderResource
|
||||
public class MetadataResource : ProviderResource<MetadataResource>
|
||||
{
|
||||
public bool Enable { get; set; }
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ using NzbDrone.Core.Notifications;
|
|||
|
||||
namespace Lidarr.Api.V1.Notifications
|
||||
{
|
||||
public class NotificationResource : ProviderResource
|
||||
public class NotificationResource : ProviderResource<NotificationResource>
|
||||
{
|
||||
public string Link { get; set; }
|
||||
public bool OnGrab { get; set; }
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Lidarr.Api.V1
|
|||
public abstract class ProviderModuleBase<TProviderResource, TProvider, TProviderDefinition> : LidarrRestModule<TProviderResource>
|
||||
where TProviderDefinition : ProviderDefinition, new()
|
||||
where TProvider : IProvider
|
||||
where TProviderResource : ProviderResource, new()
|
||||
where TProviderResource : ProviderResource<TProviderResource>, new()
|
||||
{
|
||||
private readonly IProviderFactory<TProvider, TProviderDefinition> _providerFactory;
|
||||
private readonly ProviderResourceMapper<TProviderResource, TProviderDefinition> _resourceMapper;
|
||||
|
@ -123,12 +123,9 @@ namespace Lidarr.Api.V1
|
|||
var providerResource = _resourceMapper.ToResource(providerDefinition);
|
||||
var presetDefinitions = _providerFactory.GetPresetDefinitions(providerDefinition);
|
||||
|
||||
providerResource.Presets = presetDefinitions.Select(v =>
|
||||
{
|
||||
var presetResource = _resourceMapper.ToResource(v);
|
||||
|
||||
return presetResource as ProviderResource;
|
||||
}).ToList();
|
||||
providerResource.Presets = presetDefinitions
|
||||
.Select(v => _resourceMapper.ToResource(v))
|
||||
.ToList();
|
||||
|
||||
result.Add(providerResource);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ using NzbDrone.Core.ThingiProvider;
|
|||
|
||||
namespace Lidarr.Api.V1
|
||||
{
|
||||
public class ProviderResource : RestResource
|
||||
public class ProviderResource<T> : RestResource
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public List<Field> Fields { get; set; }
|
||||
|
@ -17,11 +17,11 @@ namespace Lidarr.Api.V1
|
|||
public ProviderMessage Message { get; set; }
|
||||
public HashSet<int> Tags { get; set; }
|
||||
|
||||
public List<ProviderResource> Presets { get; set; }
|
||||
public List<T> Presets { get; set; }
|
||||
}
|
||||
|
||||
public class ProviderResourceMapper<TProviderResource, TProviderDefinition>
|
||||
where TProviderResource : ProviderResource, new()
|
||||
where TProviderResource : ProviderResource<TProviderResource>, new()
|
||||
where TProviderDefinition : ProviderDefinition, new()
|
||||
{
|
||||
public virtual TProviderResource ToResource(TProviderDefinition definition)
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace NzbDrone.Common.Serializer
|
|||
{
|
||||
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return JsonSerializer.Deserialize<T>(ref reader, options);
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
|
||||
|
|
|
@ -41,6 +41,14 @@ namespace NzbDrone.Integration.Test.ApiTests
|
|||
return field;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void all_preset_fields_should_be_set_correctly()
|
||||
{
|
||||
var schema = GetNewznabSchemav1();
|
||||
|
||||
schema.Presets.Any(x => x.SupportsRss).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void v2_categories_should_be_array()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue