feat(#13): register CalendarSubscriptionService and add public /calendar/{token}.ics endpoint
This commit is contained in:
@@ -23,6 +23,7 @@ builder.AddNpgsqlDataSource("gmrelaydb");
|
||||
builder.Services.AddSingleton<TelegramAuthService>();
|
||||
builder.Services.AddSingleton<ISessionStore, SessionService>();
|
||||
builder.Services.AddScoped<AuthorizedSessionService>();
|
||||
builder.Services.AddScoped<CalendarSubscriptionService>();
|
||||
|
||||
// Add Bot Client
|
||||
builder.Services.AddSingleton<ITelegramBotClient>(sp =>
|
||||
@@ -145,6 +146,24 @@ app.MapPost("/auth/logout", async (HttpContext context) =>
|
||||
return Results.Redirect("/");
|
||||
});
|
||||
|
||||
// Public calendar subscription endpoint (no auth required)
|
||||
app.MapGet("/calendar/{token}.ics", async (
|
||||
string token,
|
||||
CalendarSubscriptionService service,
|
||||
CancellationToken ct) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var ics = await service.GetIcsAsync(token, ct);
|
||||
var bytes = System.Text.Encoding.UTF8.GetBytes(ics);
|
||||
return Results.File(bytes, "text/calendar", "schedule.ics");
|
||||
}
|
||||
catch (SubscriptionNotFoundException)
|
||||
{
|
||||
return Results.NotFound();
|
||||
}
|
||||
});
|
||||
|
||||
app.Run();
|
||||
|
||||
static ClaimsPrincipal CreateTelegramPrincipal(long telegramId, string name)
|
||||
|
||||
Reference in New Issue
Block a user