Send.cs 887 B

1234567891011121314151617181920212223242526272829
  1. using Web.Api.Common;
  2. using Web.Api.Extensions;
  3. using MediatR;
  4. using System.Security.Claims;
  5. namespace Web.Api.Endpoints.Note;
  6. /// <summary>쪽지 전송</summary>
  7. internal sealed class Send : IEndpoint
  8. {
  9. public void MapEndpoint(IEndpointRouteBuilder app)
  10. {
  11. /// 쪽지 발송 (AppHub ReceiveNote 실시간 알림. 시스템 쪽지도 이 경로 사용)
  12. app.MapPost("api/note/send", async (
  13. Application.Features.Api.Note.SendNote.Command body,
  14. ClaimsPrincipal user,
  15. ISender sender,
  16. CancellationToken ct
  17. ) => {
  18. var memberID = user.GetRequiredMemberID();
  19. var command = body with { SenderMemberID = memberID };
  20. var data = await sender.Send(command, ct);
  21. return ApiResponse.Ok(data);
  22. })
  23. .WithTags("Note")
  24. .RequireAuthorization();
  25. }
  26. }