Add forwarding, friend controls, and benefits

Add message forwarding and reply lookup, friend removal and blocking endpoints, and database-backed Govor+ privileges with customizable profile tags. Include migrations, integration tests, and updated API and operations documentation.
This commit is contained in:
Artemy
2026-10-31 18:29:40 +07:00
parent a3401ceedf
commit 632ac04b56
78 changed files with 5284 additions and 720 deletions
@@ -0,0 +1,30 @@
using Govor.Application.Friends;
using Govor.Application.Infrastructure.Extensions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Govor.API.Controllers.Friends;
[ApiController]
[Authorize]
[Route("api/friends/{userId:guid}")]
public sealed class FriendManagementController(IFriendshipService friends, IFriendsBlockService blocks,
ICurrentUserService currentUser) : ControllerBase
{
[HttpDelete]
public Task<IActionResult> Remove(Guid userId) => Execute(() => friends.RemoveFriendAsync(userId, currentUser.GetCurrentUserId()));
[HttpPut("block")]
public Task<IActionResult> Block(Guid userId) => Execute(() => blocks.BlockFriendRequestAsync(userId, currentUser.GetCurrentUserId()));
[HttpDelete("block")]
public Task<IActionResult> Unblock(Guid userId) => Execute(() => blocks.UnblockFriendRequestAsync(userId, currentUser.GetCurrentUserId()));
private async Task<IActionResult> Execute(Func<Task> action)
{
try { await action(); return NoContent(); }
catch (ArgumentException ex) { return BadRequest(new { error = ex.Message }); }
catch (KeyNotFoundException) { return NotFound(); }
catch (UnauthorizedAccessException) { return Forbid(); }
}
}