mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
get urls to validate from API
This commit is contained in:
parent
dbc7944cdd
commit
4dcbdb3e89
16 changed files with 162 additions and 6 deletions
6
src/FilterLists.Agent/Core/Entities/IEntityUrls.cs
Normal file
6
src/FilterLists.Agent/Core/Entities/IEntityUrls.cs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
namespace FilterLists.Agent.Core.Entities
|
||||
{
|
||||
public interface IEntityUrls
|
||||
{
|
||||
}
|
||||
}
|
||||
12
src/FilterLists.Agent/Core/Entities/LicenseUrls.cs
Normal file
12
src/FilterLists.Agent/Core/Entities/LicenseUrls.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Agent.Core.Entities
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class LicenseUrls : IEntityUrls
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public Uri DescriptionUrl { get; set; }
|
||||
}
|
||||
}
|
||||
22
src/FilterLists.Agent/Core/Entities/ListUrls.cs
Normal file
22
src/FilterLists.Agent/Core/Entities/ListUrls.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Agent.Core.Entities
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class ListUrls : IEntityUrls
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public Uri ChatUrl { get; private set; }
|
||||
public Uri DescriptionSourceUrl { get; private set; }
|
||||
public Uri DonateUrl { get; private set; }
|
||||
public Uri ForumUrl { get; private set; }
|
||||
public Uri HomeUrl { get; private set; }
|
||||
public Uri IssuesUrl { get; private set; }
|
||||
public Uri PolicyUrl { get; private set; }
|
||||
public Uri SubmissionUrl { get; private set; }
|
||||
public Uri ViewUrl { get; private set; }
|
||||
public Uri ViewUrlMirror1 { get; private set; }
|
||||
public Uri ViewUrlMirror2 { get; private set; }
|
||||
}
|
||||
}
|
||||
11
src/FilterLists.Agent/Core/Entities/MaintainerUrls.cs
Normal file
11
src/FilterLists.Agent/Core/Entities/MaintainerUrls.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Agent.Core.Entities
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class MaintainerUrls : IEntityUrls
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string HomeUrl { get; set; }
|
||||
}
|
||||
}
|
||||
12
src/FilterLists.Agent/Core/Entities/SoftwareUrls.cs
Normal file
12
src/FilterLists.Agent/Core/Entities/SoftwareUrls.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Agent.Core.Entities
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class SoftwareUrls : IEntityUrls
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string DownloadUrl { get; set; }
|
||||
public string HomeUrl { get; set; }
|
||||
}
|
||||
}
|
||||
11
src/FilterLists.Agent/Core/Entities/SyntaxUrls.cs
Normal file
11
src/FilterLists.Agent/Core/Entities/SyntaxUrls.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Agent.Core.Entities
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class SyntaxUrls : IEntityUrls
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string DefinitionUrl { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using FilterLists.Agent.Core.Entities;
|
||||
|
||||
namespace FilterLists.Agent.Core.Interfaces
|
||||
{
|
||||
public interface IEntityUrlsRepository
|
||||
{
|
||||
Task<IEnumerable<TEntityUrls>> GetAllAsync<TEntityUrls>() where TEntityUrls : IEntityUrls, new();
|
||||
}
|
||||
}
|
||||
|
|
@ -26,6 +26,7 @@ public static void RegisterAgentServices(this IServiceCollection services)
|
|||
services.AddHttpClient<AgentHttpClient>();
|
||||
services.AddSingleton<IFilterListsApiClient, FilterListsApiClient>();
|
||||
services.AddTransient<IListInfoRepository, ListInfoRepository>();
|
||||
services.AddTransient<IEntityUrlsRepository, EntityUrlsRepository>();
|
||||
}
|
||||
|
||||
private static void AddConfiguration(this IServiceCollection services)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
using FilterLists.Agent.Core.Interfaces;
|
||||
using MediatR;
|
||||
|
||||
namespace FilterLists.Agent.Features.Archiver
|
||||
namespace FilterLists.Agent.Features.Lists
|
||||
{
|
||||
public static class CaptureLists
|
||||
{
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
using LibGit2Sharp;
|
||||
using MediatR;
|
||||
|
||||
namespace FilterLists.Agent.Features.Archiver
|
||||
namespace FilterLists.Agent.Features.Lists
|
||||
{
|
||||
public static class CommitLists
|
||||
{
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
using MediatR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace FilterLists.Agent.Features.Archiver
|
||||
namespace FilterLists.Agent.Features.Lists
|
||||
{
|
||||
public static class DownloadLists
|
||||
{
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
using FilterLists.Agent.Infrastructure.Clients;
|
||||
using MediatR;
|
||||
|
||||
namespace FilterLists.Agent.Features.Archiver
|
||||
namespace FilterLists.Agent.Features.Lists
|
||||
{
|
||||
public static class DownloadRawText
|
||||
{
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
using SharpCompress.Archives.SevenZip;
|
||||
using SharpCompress.Common;
|
||||
|
||||
namespace FilterLists.Agent.Features.Archiver
|
||||
namespace FilterLists.Agent.Features.Lists
|
||||
{
|
||||
public static class DownloadSevenZip
|
||||
{
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
using SharpCompress.Common;
|
||||
using SharpCompress.Readers;
|
||||
|
||||
namespace FilterLists.Agent.Features.Archiver
|
||||
namespace FilterLists.Agent.Features.Lists
|
||||
{
|
||||
public static class DownloadZip
|
||||
{
|
||||
29
src/FilterLists.Agent/Features/Urls/ValidateUrls.cs
Normal file
29
src/FilterLists.Agent/Features/Urls/ValidateUrls.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediatR;
|
||||
|
||||
namespace FilterLists.Agent.Features.Urls
|
||||
{
|
||||
public static class ValidateUrls
|
||||
{
|
||||
public class Command : IRequest
|
||||
{
|
||||
}
|
||||
|
||||
public class Handler : AsyncRequestHandler<Command>
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
|
||||
public Handler(IMediator mediator)
|
||||
{
|
||||
_mediator = mediator;
|
||||
}
|
||||
|
||||
protected override async Task Handle(Command request, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using FilterLists.Agent.Core.Entities;
|
||||
using FilterLists.Agent.Core.Interfaces;
|
||||
using FilterLists.Agent.Infrastructure.Clients;
|
||||
using RestSharp;
|
||||
|
||||
namespace FilterLists.Agent.Infrastructure.Repositories
|
||||
{
|
||||
public class EntityUrlsRepository : IEntityUrlsRepository
|
||||
{
|
||||
private readonly IFilterListsApiClient _apiClient;
|
||||
|
||||
public EntityUrlsRepository(IFilterListsApiClient apiClient)
|
||||
{
|
||||
_apiClient = apiClient;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<TEntityUrls>> GetAllAsync<TEntityUrls>()
|
||||
where TEntityUrls : IEntityUrls, new()
|
||||
{
|
||||
string entityEndpoint;
|
||||
switch (typeof(TEntityUrls).Name)
|
||||
{
|
||||
case nameof(SyntaxUrls):
|
||||
entityEndpoint = typeof(TEntityUrls).Name.Replace("Urls", "es").ToLowerInvariant();
|
||||
break;
|
||||
case nameof(SoftwareUrls):
|
||||
entityEndpoint = typeof(TEntityUrls).Name.Replace("Urls", "").ToLowerInvariant();
|
||||
break;
|
||||
default:
|
||||
entityEndpoint = typeof(TEntityUrls).Name.Replace("Urls", "s").ToLowerInvariant();
|
||||
break;
|
||||
}
|
||||
|
||||
var endpoint = $"{entityEndpoint}/seed";
|
||||
var request = new RestRequest(endpoint);
|
||||
return await _apiClient.ExecuteAsync<IEnumerable<TEntityUrls>>(request);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue