| 123456789101112131415161718192021222324252627282930313233 |
- using System.Security.Claims;
- using Application.Abstractions.Messaging;
- using Web.Api.Common;
- using Web.Api.Extensions;
- namespace Web.Api.Endpoints.Feed;
- internal sealed class ToggleBookmark : IEndpoint
- {
- public void MapEndpoint(IEndpointRouteBuilder app)
- {
- app.MapPost("api/feed/post/{postID:int}/bookmark", async (
- int postID,
- ClaimsPrincipal user,
- ISender sender,
- CancellationToken ct
- ) => {
- var memberID = user.GetMemberID();
- if (memberID is null)
- {
- return ApiResponse.Fail(StatusCodes.Status401Unauthorized, "Invalid token");
- }
- var command = new Application.Features.Api.Feed.ToggleBookmark.Command(postID, memberID.Value);
- var result = await sender.Send(command, ct);
- return result.Match(data => ApiResponse.Ok(data), CustomResults.Problem);
- })
- .WithTags("Feed")
- .RequireAuthorization();
- }
- }
|