mirror of
https://github.com/Govor-team/Govor.git
synced 2026-11-16 20:56:03 +00:00
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:
@@ -0,0 +1,28 @@
|
||||
using AutoMapper;
|
||||
using Govor.Application.Infrastructure.Extensions;
|
||||
using Govor.Application.Messages;
|
||||
using Govor.Contracts.Responses;
|
||||
using Govor.Domain;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Govor.API.Controllers;
|
||||
|
||||
/// <summary>Loads a reply target outside the current history page without exposing another conversation.</summary>
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
[Route("api/messages")]
|
||||
public sealed class MessageLookupController(GovorDbContext db, ICurrentUserService currentUser, IMapper mapper) : ControllerBase
|
||||
{
|
||||
[HttpGet("{messageId:guid}")]
|
||||
public async Task<IActionResult> Get(Guid messageId)
|
||||
{
|
||||
var message = await db.Messages.AsNoTracking().Include(m => m.MediaAttachments).ThenInclude(m => m.MediaFile)
|
||||
.Include(m => m.Reactions).Include(m => m.MessageViews).AsSplitQuery()
|
||||
.SingleOrDefaultAsync(m => m.Id == messageId);
|
||||
if (message is null || !await db.HasChatAccessAsync(currentUser.GetCurrentUserId(), message.RecipientId, message.RecipientType))
|
||||
return NotFound();
|
||||
return Ok(mapper.Map<MessageResponse>(message));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user