♻️ Move the chat part of the Sphere service to the Messager service

This commit is contained in:
2026-01-01 22:09:08 +08:00
parent c503083df7
commit ab37bbc7b0
50 changed files with 3042 additions and 611 deletions

View File

@@ -1,6 +1,8 @@
using System.Globalization;
using System.Text.Json;
using System.Text.Json.Serialization;
using DysonNetwork.Messager.Chat;
using DysonNetwork.Messager.Chat.Realtime;
using NodaTime;
using NodaTime.Serialization.SystemTextJson;
@@ -8,45 +10,52 @@ namespace DysonNetwork.Messager.Startup;
public static class ServiceCollectionExtensions
{
public static IServiceCollection AddAppServices(this IServiceCollection services)
extension(IServiceCollection services)
{
services.AddDbContext<AppDatabase>();
services.AddHttpContextAccessor();
services.AddHttpClient();
services
.AddControllers()
.AddJsonOptions(options =>
{
options.JsonSerializerOptions.NumberHandling =
JsonNumberHandling.AllowNamedFloatingPointLiterals;
options.JsonSerializerOptions.PropertyNamingPolicy =
JsonNamingPolicy.SnakeCaseLower;
options.JsonSerializerOptions.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb);
});
services.AddGrpc(options =>
public IServiceCollection AddAppServices()
{
options.EnableDetailedErrors = true;
});
services.AddGrpcReflection();
services.AddDbContext<AppDatabase>();
services.AddHttpContextAccessor();
return services;
}
services.AddHttpClient();
public static IServiceCollection AddAppAuthentication(this IServiceCollection services)
{
services.AddAuthorization();
return services;
}
services
.AddControllers()
.AddJsonOptions(options =>
{
options.JsonSerializerOptions.NumberHandling =
JsonNumberHandling.AllowNamedFloatingPointLiterals;
options.JsonSerializerOptions.PropertyNamingPolicy =
JsonNamingPolicy.SnakeCaseLower;
public static IServiceCollection AddAppBusinessServices(
this IServiceCollection services,
IConfiguration configuration
)
{
return services;
options.JsonSerializerOptions.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb);
});
services.AddGrpc(options =>
{
options.EnableDetailedErrors = true;
});
services.AddGrpcReflection();
return services;
}
public IServiceCollection AddAppAuthentication()
{
services.AddAuthorization();
return services;
}
public IServiceCollection AddAppBusinessServices(IConfiguration configuration
)
{
services.AddScoped<ChatRoomService>();
services.AddScoped<ChatService>();
services.AddScoped<IRealtimeService, LiveKitRealtimeService>();
services.AddHostedService<BroadcastEventHandler>();
return services;
}
}
}