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,31 @@
using Govor.Application.Friends;
using Govor.Domain.Models;
using Microsoft.EntityFrameworkCore;
namespace Govor.Application.Tests.Integration.Friends;
[TestFixture]
public sealed class FriendRemovalTests
{
[TestCase(FriendshipStatus.Pending)]
[TestCase(FriendshipStatus.Blocked)]
[TestCase(FriendshipStatus.Rejected)]
[TestCase(FriendshipStatus.Accepted)]
public async Task RemovalChangesOnlyAcceptedFriendshipAndRetainsHistory(FriendshipStatus status)
{
using var db = new TestDatabase();
db.Context.Friendships.Add(new Friendship { Id = Guid.NewGuid(), RequesterId = db.Alice, AddresseeId = db.Bob, Status = status });
await db.Context.SaveChangesAsync();
var message = db.AddMessage();
var service = new FriendshipService(db.Context);
await service.RemoveFriendAsync(db.Bob, db.Alice);
await service.RemoveFriendAsync(db.Alice, db.Bob);
Assert.That((await db.Context.Friendships.AsNoTracking().SingleAsync()).Status,
Is.EqualTo(status == FriendshipStatus.Accepted ? FriendshipStatus.Rejected : status));
Assert.That(await db.Context.Messages.AnyAsync(m => m.Id == message.Id), Is.True);
Assert.That(await db.Context.PrivateChats.AnyAsync(c => c.Id == db.ChatId), Is.True);
Assert.ThrowsAsync<ArgumentException>(() => service.RemoveFriendAsync(db.Alice, db.Alice));
Assert.ThrowsAsync<ArgumentException>(() => service.RemoveFriendAsync(Guid.Empty, db.Alice));
Assert.ThrowsAsync<ArgumentException>(() => service.RemoveFriendAsync(db.Alice, Guid.Empty));
}
}