Done mixing

This commit is contained in:
2025-07-15 16:10:57 +08:00
parent 3c11c4f3be
commit 8fbc81cab9
34 changed files with 3314 additions and 1378 deletions

View File

@@ -1,21 +1,17 @@
using System.Net;
using DysonNetwork.Sphere.Connection;
using DysonNetwork.Sphere.Permission;
using DysonNetwork.Sphere.Storage;
using DysonNetwork.Shared.Auth;
using Microsoft.AspNetCore.HttpOverrides;
using Prometheus;
using tusdotnet;
using tusdotnet.Stores;
namespace DysonNetwork.Sphere.Startup;
public static class ApplicationConfiguration
{
public static WebApplication ConfigureAppMiddleware(this WebApplication app, IConfiguration configuration, TusDiskStore tusDiskStore)
public static WebApplication ConfigureAppMiddleware(this WebApplication app, IConfiguration configuration)
{
app.MapMetrics();
app.MapOpenApi();
app.UseMiddleware<ClientTypeMiddleware>();
app.UseSwagger();
app.UseSwaggerUI();
@@ -44,8 +40,6 @@ public static class ApplicationConfiguration
app.MapStaticAssets().RequireRateLimiting("fixed");
app.MapRazorPages().RequireRateLimiting("fixed");
app.MapTus("/files/tus", _ => Task.FromResult(TusService.BuildConfiguration(tusDiskStore)));
return app;
}

View File

@@ -1,7 +1,4 @@
using DysonNetwork.Sphere.Storage;
using DysonNetwork.Sphere.WebReader;
using DysonNetwork.Sphere.Storage.Handlers;
using DysonNetwork.Sphere.Wallet;
using Quartz;
namespace DysonNetwork.Sphere.Startup;
@@ -19,63 +16,15 @@ public static class ScheduledJobsConfiguration
.WithIdentity("AppDatabaseRecyclingTrigger")
.WithCronSchedule("0 0 0 * * ?"));
var cloudFilesRecyclingJob = new JobKey("CloudFilesUnusedRecycling");
q.AddJob<CloudFileUnusedRecyclingJob>(opts => opts.WithIdentity(cloudFilesRecyclingJob));
q.AddTrigger(opts => opts
.ForJob(cloudFilesRecyclingJob)
.WithIdentity("CloudFilesUnusedRecyclingTrigger")
.WithSimpleSchedule(o => o.WithIntervalInHours(1).RepeatForever())
);
var actionLogFlushJob = new JobKey("ActionLogFlush");
q.AddJob<ActionLogFlushJob>(opts => opts.WithIdentity(actionLogFlushJob));
q.AddTrigger(opts => opts
.ForJob(actionLogFlushJob)
.WithIdentity("ActionLogFlushTrigger")
.WithSimpleSchedule(o => o
.WithIntervalInMinutes(5)
.RepeatForever())
);
var readReceiptFlushJob = new JobKey("ReadReceiptFlush");
q.AddJob<ReadReceiptFlushJob>(opts => opts.WithIdentity(readReceiptFlushJob));
q.AddTrigger(opts => opts
.ForJob(readReceiptFlushJob)
.WithIdentity("ReadReceiptFlushTrigger")
.WithSimpleSchedule(o => o
.WithIntervalInSeconds(60)
.RepeatForever())
);
var lastActiveFlushJob = new JobKey("LastActiveFlush");
q.AddJob<LastActiveFlushJob>(opts => opts.WithIdentity(lastActiveFlushJob));
q.AddTrigger(opts => opts
.ForJob(lastActiveFlushJob)
.WithIdentity("LastActiveFlushTrigger")
.WithSimpleSchedule(o => o
.WithIntervalInMinutes(5)
.RepeatForever())
);
var postViewFlushJob = new JobKey("PostViewFlush");
q.AddJob<PostViewFlushJob>(opts => opts.WithIdentity(postViewFlushJob));
q.AddTrigger(opts => opts
.ForJob(postViewFlushJob)
.WithIdentity("PostViewFlushTrigger")
.WithSimpleSchedule(o => o
.WithIntervalInMinutes(1)
.RepeatForever())
);
var subscriptionRenewalJob = new JobKey("SubscriptionRenewal");
q.AddJob<SubscriptionRenewalJob>(opts => opts.WithIdentity(subscriptionRenewalJob));
q.AddTrigger(opts => opts
.ForJob(subscriptionRenewalJob)
.WithIdentity("SubscriptionRenewalTrigger")
.WithSimpleSchedule(o => o
.WithIntervalInMinutes(30)
.RepeatForever())
);
// var postViewFlushJob = new JobKey("PostViewFlush");
// q.AddJob<PostViewFlushJob>(opts => opts.WithIdentity(postViewFlushJob));
// q.AddTrigger(opts => opts
// .ForJob(postViewFlushJob)
// .WithIdentity("PostViewFlushTrigger")
// .WithSimpleSchedule(o => o
// .WithIntervalInMinutes(1)
// .RepeatForever())
// );
var webFeedScraperJob = new JobKey("WebFeedScraper");
q.AddJob<WebFeedScraperJob>(opts => opts.WithIdentity(webFeedScraperJob));

View File

@@ -21,9 +21,7 @@ using DysonNetwork.Shared.Proto;
using DysonNetwork.Sphere.WebReader;
using DysonNetwork.Sphere.Developer;
using DysonNetwork.Sphere.Discovery;
using DysonNetwork.Sphere.Safety;
using tusdotnet.Stores;
using PermissionService = DysonNetwork.Sphere.Permission.PermissionService;
namespace DysonNetwork.Sphere.Startup;
@@ -90,12 +88,6 @@ public static class ServiceCollectionExtensions
{
services.AddCors();
services.AddAuthorization();
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = AuthConstants.SchemeName;
options.DefaultChallengeScheme = AuthConstants.SchemeName;
})
.AddScheme<DysonTokenAuthOptions, DysonTokenAuthHandler>(AuthConstants.SchemeName, _ => { });
return services;
}
@@ -146,17 +138,6 @@ public static class ServiceCollectionExtensions
return services;
}
public static IServiceCollection AddAppFileStorage(this IServiceCollection services, IConfiguration configuration)
{
var tusStorePath = configuration.GetSection("Tus").GetValue<string>("StorePath")!;
Directory.CreateDirectory(tusStorePath);
var tusDiskStore = new TusDiskStore(tusStorePath);
services.AddSingleton(tusDiskStore);
return services;
}
public static IServiceCollection AddAppFlushHandlers(this IServiceCollection services)
{
services.AddSingleton<FlushBufferService>();
@@ -169,7 +150,6 @@ public static class ServiceCollectionExtensions
{
services.Configure<GeoIpOptions>(configuration.GetSection("GeoIP"));
services.AddScoped<GeoIpService>();
services.AddScoped<PermissionService>();
services.AddScoped<PublisherService>();
services.AddScoped<PublisherSubscriptionService>();
services.AddScoped<ActivityService>();
@@ -181,7 +161,6 @@ public static class ServiceCollectionExtensions
services.AddScoped<IRealtimeService, LiveKitRealtimeService>();
services.AddScoped<WebReaderService>();
services.AddScoped<WebFeedService>();
services.AddScoped<SafetyService>();
services.AddScoped<DiscoveryService>();
services.AddScoped<CustomAppService>();