Files
Ping/backend/Hosts/Ping.Api/Endpoints/CallEndpoints.cs
Admin 0623875dfa Add Ping backend
.NET 10 solution for Ping, a Discord style chat app: Domain, Application
and Infrastructure projects plus the Api host. SignalR for chat and
presence, LiveKit for call tokens, EF Core on Postgres, S3 compatible
storage for attachments, and OIDC auth shared with the Musify Zitadel
instance. Includes the Compose stack for local development.
2026-09-21 19:32:55 +02:00

33 lines
1.1 KiB
C#

using Mediator;
using Ping.Api.Authentication;
using Ping.Api.Extensions;
using Ping.Application.Calls;
namespace Ping.Api.Endpoints;
public static class CallEndpoints
{
public static IEndpointRouteBuilder MapCallEndpoints(this IEndpointRouteBuilder app)
{
var group = app.MapGroup("/channels/{channelId:guid}/call-token")
.WithTags("Calls")
.RequireAuthorization();
group.MapPost("/", RequestCallToken)
.WithName("RequestCallToken")
.WithSummary("Request A Livekit Access Token To Join The Voice/Video Call For A Channel.")
.Produces<Application.Calls.Responses.CallTokenResponse>()
.ProducesValidationProblem()
.Produces(StatusCodes.Status404NotFound);
return app;
}
private static async Task<IResult> RequestCallToken(
IMediator mediator, CurrentUser currentUser, Guid channelId, CancellationToken cancellationToken)
{
var result = await mediator.Send(new RequestCallTokenCommand(currentUser.RequiredId, channelId), cancellationToken);
return result.ToHttpResult();
}
}