using Web.Api.Common;
using Web.Api.Extensions;
using Application.Abstractions.Messaging;
using System.Security.Claims;

namespace Web.Api.Endpoints.Forum.Comment;

internal sealed class Mention : IEndpoint
{
    public void MapEndpoint(IEndpointRouteBuilder app)
    {
        app.MapGet("api/forum/comments/mention", async (
            ClaimsPrincipal user,
            ISender sender,
            CancellationToken ct,
            int postID,
            string? keyword = null
        ) =>
        {
            var memberID = user.GetMemberID();

            return ApiResponse.Ok(
                await sender.Send(
                    new Application.Features.Api.Forum.Comment.Mention.Query(postID, keyword, memberID),
                    ct
                )
            );
        })
        .WithTags("Forum")
        .AllowAnonymous();
    }
}
