History.cs 895 B

12345678910111213141516171819202122232425262728
  1. using Application.Abstractions.Messaging;
  2. using Web.Api.Common;
  3. using Web.Api.Extensions;
  4. namespace Web.Api.Endpoints.Chat;
  5. /// <summary>룸 최근 메시지 히스토리 — roomKey = main | stock:{code}, 익명 열람 허용 (게스트 읽기 — d0 §5-④)</summary>
  6. internal sealed class History : IEndpoint
  7. {
  8. public void MapEndpoint(IEndpointRouteBuilder app)
  9. {
  10. app.MapGet("api/chat/rooms/{roomKey}/messages", async (
  11. string roomKey,
  12. ISender sender,
  13. CancellationToken ct,
  14. int count = 50
  15. ) => {
  16. var result = await sender.Send(new Application.Features.Api.Chat.GetHistory.Query(roomKey, count), ct);
  17. return result.Match(
  18. data => ApiResponse.Ok(data),
  19. CustomResults.Problem
  20. );
  21. })
  22. .WithTags("Chat")
  23. .AllowAnonymous();
  24. }
  25. }