mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-18 21:34:28 -04:00
Fixed: Adding indexers from presets
This commit is contained in:
+1
-1
@@ -8,7 +8,7 @@ namespace NzbDrone.Common.Serializer
|
|||||||
{
|
{
|
||||||
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
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)
|
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
|
||||||
|
|||||||
@@ -41,6 +41,14 @@ namespace NzbDrone.Integration.Test.ApiTests
|
|||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void all_preset_fields_should_be_set_correctly()
|
||||||
|
{
|
||||||
|
var schema = GetNewznabSchemav1();
|
||||||
|
|
||||||
|
schema.Presets.Any(x => x.SupportsRss).Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void v2_categories_should_be_array()
|
public void v2_categories_should_be_array()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using NzbDrone.Core.Indexers;
|
|||||||
|
|
||||||
namespace Readarr.Api.V1.DownloadClient
|
namespace Readarr.Api.V1.DownloadClient
|
||||||
{
|
{
|
||||||
public class DownloadClientResource : ProviderResource
|
public class DownloadClientResource : ProviderResource<DownloadClientResource>
|
||||||
{
|
{
|
||||||
public bool Enable { get; set; }
|
public bool Enable { get; set; }
|
||||||
public DownloadProtocol Protocol { get; set; }
|
public DownloadProtocol Protocol { get; set; }
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ using NzbDrone.Core.ImportLists;
|
|||||||
|
|
||||||
namespace Readarr.Api.V1.ImportLists
|
namespace Readarr.Api.V1.ImportLists
|
||||||
{
|
{
|
||||||
public class ImportListResource : ProviderResource
|
public class ImportListResource : ProviderResource<ImportListResource>
|
||||||
{
|
{
|
||||||
public bool EnableAutomaticAdd { get; set; }
|
public bool EnableAutomaticAdd { get; set; }
|
||||||
public ImportListMonitorType ShouldMonitor { get; set; }
|
public ImportListMonitorType ShouldMonitor { get; set; }
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ using NzbDrone.Core.Indexers;
|
|||||||
|
|
||||||
namespace Readarr.Api.V1.Indexers
|
namespace Readarr.Api.V1.Indexers
|
||||||
{
|
{
|
||||||
public class IndexerResource : ProviderResource
|
public class IndexerResource : ProviderResource<IndexerResource>
|
||||||
{
|
{
|
||||||
public bool EnableRss { get; set; }
|
public bool EnableRss { get; set; }
|
||||||
public bool EnableAutomaticSearch { get; set; }
|
public bool EnableAutomaticSearch { get; set; }
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Readarr.Api.V1.Metadata
|
namespace Readarr.Api.V1.Metadata
|
||||||
{
|
{
|
||||||
public class MetadataResource : ProviderResource
|
public class MetadataResource : ProviderResource<MetadataResource>
|
||||||
{
|
{
|
||||||
public bool Enable { get; set; }
|
public bool Enable { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ using NzbDrone.Core.Notifications;
|
|||||||
|
|
||||||
namespace Readarr.Api.V1.Notifications
|
namespace Readarr.Api.V1.Notifications
|
||||||
{
|
{
|
||||||
public class NotificationResource : ProviderResource
|
public class NotificationResource : ProviderResource<NotificationResource>
|
||||||
{
|
{
|
||||||
public string Link { get; set; }
|
public string Link { get; set; }
|
||||||
public bool OnGrab { get; set; }
|
public bool OnGrab { get; set; }
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace Readarr.Api.V1
|
|||||||
public abstract class ProviderModuleBase<TProviderResource, TProvider, TProviderDefinition> : ReadarrRestModule<TProviderResource>
|
public abstract class ProviderModuleBase<TProviderResource, TProvider, TProviderDefinition> : ReadarrRestModule<TProviderResource>
|
||||||
where TProviderDefinition : ProviderDefinition, new()
|
where TProviderDefinition : ProviderDefinition, new()
|
||||||
where TProvider : IProvider
|
where TProvider : IProvider
|
||||||
where TProviderResource : ProviderResource, new()
|
where TProviderResource : ProviderResource<TProviderResource>, new()
|
||||||
{
|
{
|
||||||
private readonly IProviderFactory<TProvider, TProviderDefinition> _providerFactory;
|
private readonly IProviderFactory<TProvider, TProviderDefinition> _providerFactory;
|
||||||
private readonly ProviderResourceMapper<TProviderResource, TProviderDefinition> _resourceMapper;
|
private readonly ProviderResourceMapper<TProviderResource, TProviderDefinition> _resourceMapper;
|
||||||
@@ -121,12 +121,9 @@ namespace Readarr.Api.V1
|
|||||||
var providerResource = _resourceMapper.ToResource(providerDefinition);
|
var providerResource = _resourceMapper.ToResource(providerDefinition);
|
||||||
var presetDefinitions = _providerFactory.GetPresetDefinitions(providerDefinition);
|
var presetDefinitions = _providerFactory.GetPresetDefinitions(providerDefinition);
|
||||||
|
|
||||||
providerResource.Presets = presetDefinitions.Select(v =>
|
providerResource.Presets = presetDefinitions
|
||||||
{
|
.Select(v => _resourceMapper.ToResource(v))
|
||||||
var presetResource = _resourceMapper.ToResource(v);
|
.ToList();
|
||||||
|
|
||||||
return presetResource as ProviderResource;
|
|
||||||
}).ToList();
|
|
||||||
|
|
||||||
result.Add(providerResource);
|
result.Add(providerResource);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using Readarr.Http.REST;
|
|||||||
|
|
||||||
namespace Readarr.Api.V1
|
namespace Readarr.Api.V1
|
||||||
{
|
{
|
||||||
public class ProviderResource : RestResource
|
public class ProviderResource<T> : RestResource
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public List<Field> Fields { get; set; }
|
public List<Field> Fields { get; set; }
|
||||||
@@ -17,11 +17,11 @@ namespace Readarr.Api.V1
|
|||||||
public ProviderMessage Message { get; set; }
|
public ProviderMessage Message { get; set; }
|
||||||
public HashSet<int> Tags { 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>
|
public class ProviderResourceMapper<TProviderResource, TProviderDefinition>
|
||||||
where TProviderResource : ProviderResource, new()
|
where TProviderResource : ProviderResource<TProviderResource>, new()
|
||||||
where TProviderDefinition : ProviderDefinition, new()
|
where TProviderDefinition : ProviderDefinition, new()
|
||||||
{
|
{
|
||||||
public virtual TProviderResource ToResource(TProviderDefinition definition)
|
public virtual TProviderResource ToResource(TProviderDefinition definition)
|
||||||
|
|||||||
Reference in New Issue
Block a user