Update configuration and enhance media processing: add stream token TTL and timeout settings in .env.example, improve error handling in media endpoints, and refactor command handlers for asynchronous operations. Update documentation to reflect current application state and features.
This commit is contained in:
@@ -98,7 +98,7 @@ public static partial class ChannelEndpoints
|
||||
cancellationToken
|
||||
);
|
||||
if (!result.IsSuccess)
|
||||
storage.DeleteAudio(templateId);
|
||||
await storage.DeleteAudioAsync(templateId, cancellationToken);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ public static partial class ChannelEndpoints
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new RenderBumperPreviewQuery(id, templateId),
|
||||
new RenderBumperPreviewCommand(id, templateId),
|
||||
cancellationToken
|
||||
);
|
||||
return result.IsSuccess ? Results.NoContent() : result.ToHttpResult();
|
||||
|
||||
@@ -84,7 +84,7 @@ public static class MediaEndpoints
|
||||
);
|
||||
if (!result.IsSuccess)
|
||||
{
|
||||
storage.DeleteUpload(token);
|
||||
await storage.DeleteUploadAsync(token, cancellationToken);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
|
||||
@@ -95,11 +95,18 @@ public static class StreamingEndpoints
|
||||
HttpRequest request,
|
||||
HttpResponse response,
|
||||
StreamTokenService tokens,
|
||||
IIdentityService identity,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
if (!tokens.Validate(request.Cookies[StreamCookieName]))
|
||||
// Плейлист hls.js перезагружает регулярно — здесь дёшево (1 запрос на перезагрузку) сверить,
|
||||
// что зритель из токена ещё существует и не заблокирован. Так блокировка отражается почти сразу,
|
||||
// не дожидаясь истечения короткого TTL cookie; сегменты этой проверки не делают (слишком часто).
|
||||
if (tokens.Validate(request.Cookies[StreamCookieName]) is not { } userId)
|
||||
return Results.Unauthorized();
|
||||
var profile = await identity.GetProfileAsync(userId, cancellationToken);
|
||||
if (profile is null || profile.IsBlocked)
|
||||
return Results.Unauthorized();
|
||||
|
||||
var result = await sender.Send(
|
||||
@@ -124,7 +131,7 @@ public static class StreamingEndpoints
|
||||
MediaPathResolver paths
|
||||
)
|
||||
{
|
||||
if (!tokens.Validate(request.Cookies[StreamCookieName]))
|
||||
if (tokens.Validate(request.Cookies[StreamCookieName]) is null)
|
||||
return Results.Unauthorized();
|
||||
if (!SegmentFileName.IsMatch(file))
|
||||
return Results.NotFound();
|
||||
|
||||
@@ -110,8 +110,13 @@ app.UseRateLimiter();
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapOpenApi();
|
||||
app.MapScalarApiReference();
|
||||
// Схему/UI API публикуем не в проде (или явным флагом Api:EnableOpenApi=true) — чтобы в продакшене
|
||||
// не раскрывать полную карту эндпоинтов без необходимости.
|
||||
if (app.Environment.IsDevelopment() || app.Configuration.GetValue("Api:EnableOpenApi", false))
|
||||
{
|
||||
app.MapOpenApi();
|
||||
app.MapScalarApiReference();
|
||||
}
|
||||
|
||||
app.MapHealthChecks("/health");
|
||||
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"Jwt": {
|
||||
"SigningKey": "telewave-development-only-signing-key-not-for-production-0001"
|
||||
},
|
||||
"AdminSeed": {
|
||||
"Username": "admin",
|
||||
"Password": "Passw0rd!Dev"
|
||||
|
||||
Reference in New Issue
Block a user