using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using StickyBoard.Api.Common; using StickyBoard.Core.DTOs.Common; using StickyBoard.Core.DTOs.SocialAndMessaging; using StickyBoard.Core.Models; using StickyBoard.Core.Services.SocialAndMessaging; namespace StickyBoard.Api.Controllers; [ApiController] [Route("api/[controller]")] [Authorize] public sealed class MentionsController : ControllerBase { private readonly MentionService _mentions; public MentionsController(MentionService mentions) { _mentions = mentions; } // ------------------------------------------------------------ // CREATE // ------------------------------------------------------------ [HttpPost] public async Task>> Create( [FromBody] MentionCreateDto dto, CancellationToken ct) { var userId = User.GetUserId(); if (userId == Guid.Empty) return Unauthorized(ApiResponseDto.Fail("Invalid or missing token.")); var m = await _mentions.CreateAsync(userId, dto, ct); return Ok(ApiResponseDto.Ok(m)); } // ------------------------------------------------------------ // GET MY MENTIONS // ------------------------------------------------------------ [HttpGet("me")] public async Task>>> GetMyMentions(CancellationToken ct) { var userId = User.GetUserId(); if (userId == Guid.Empty) return Unauthorized(ApiResponseDto>.Fail("Invalid or missing token.")); var list = await _mentions.GetForUserAsync(userId, ct); return Ok(ApiResponseDto>.Ok(list)); } // ------------------------------------------------------------ // GET BY ENTITY (debug / admin / tooling) // ------------------------------------------------------------ [HttpGet("entity")] public async Task>>> GetByEntity( [FromQuery] EntityType type, [FromQuery] Guid entityId, CancellationToken ct) { var list = await _mentions.GetForEntityAsync(type, entityId, ct); return Ok(ApiResponseDto>.Ok(list)); } }