Added Chobit integration. Updated tests.
All checks were successful
ci / build-test (push) Successful in 2m27s
ci / publish-image (push) Has been skipped

This commit is contained in:
2026-03-14 21:46:53 -04:00
parent ee809e374f
commit aab7bee694
32 changed files with 521 additions and 108 deletions

View File

@@ -24,6 +24,7 @@ using JSMR.Infrastructure.Data.Repositories.Users;
using JSMR.Infrastructure.Data.Repositories.VoiceWorks;
using JSMR.Infrastructure.Http;
using JSMR.Infrastructure.Ingestion;
using JSMR.Infrastructure.Integrations.Chobit;
using JSMR.Infrastructure.Integrations.DLSite;
using JSMR.Infrastructure.Scanning;
using Microsoft.Extensions.DependencyInjection;
@@ -76,6 +77,9 @@ public static class InfrastructureServiceCollectionExtensions
services.AddSingleton<ITimeProvider, TokyoTimeProvider>();
services.AddHttpServices();
services.AddNewHttpServices();
services.AddScoped<IUserRepository, UserRepository>();
return services;
}
@@ -113,7 +117,50 @@ public static class InfrastructureServiceCollectionExtensions
// Register DLSiteClient as a normal scoped service
services.AddScoped<IDLSiteClient, DLSiteClient>();
services.AddScoped<IUserRepository, UserRepository>();
return services;
}
private static IServiceCollection AddNewHttpServices(this IServiceCollection services)
{
services.AddHttpClient<IDLSiteClient, DLSiteClient>((sp, http) =>
{
http.BaseAddress = new Uri("https://www.dlsite.com/");
http.DefaultRequestHeaders.UserAgent.ParseAdd("JSMR/1.0");
http.Timeout = TimeSpan.FromSeconds(15);
})
.AddResilienceHandler("dlsite", builder =>
{
builder.AddRetry(new HttpRetryStrategyOptions
{
MaxRetryAttempts = 3,
UseJitter = true,
Delay = TimeSpan.FromMilliseconds(200),
BackoffType = DelayBackoffType.Exponential,
ShouldHandle = new PredicateBuilder<HttpResponseMessage>()
.Handle<HttpRequestException>()
.HandleResult(r => (int)r.StatusCode >= 500 || (int)r.StatusCode == 429)
});
});
services.AddHttpClient<IChobitClient, ChobitClient>((sp, http) =>
{
http.BaseAddress = new Uri("https://chobit.cc/");
http.DefaultRequestHeaders.UserAgent.ParseAdd("JSMR/1.0");
http.Timeout = TimeSpan.FromSeconds(15);
})
.AddResilienceHandler("chobit", builder =>
{
builder.AddRetry(new HttpRetryStrategyOptions
{
MaxRetryAttempts = 3,
UseJitter = true,
Delay = TimeSpan.FromMilliseconds(200),
BackoffType = DelayBackoffType.Exponential,
ShouldHandle = new PredicateBuilder<HttpResponseMessage>()
.Handle<HttpRequestException>()
.HandleResult(r => (int)r.StatusCode >= 500 || (int)r.StatusCode == 429)
});
});
return services;
}