🐛 Fixes for relationships

This commit is contained in:
2025-05-17 00:09:35 +08:00
parent 88977ccda3
commit b489a79df2
2 changed files with 6 additions and 1 deletions

View File

@ -107,6 +107,11 @@ public class RelationshipController(AppDatabase db, RelationshipService rels) :
var relatedUser = await db.Accounts.FindAsync(userId);
if (relatedUser is null) return NotFound("Account was not found.");
var existing = await db.AccountRelationships.FirstOrDefaultAsync(r =>
(r.AccountId == currentUser.Id && r.RelatedId == userId) ||
(r.AccountId == userId && r.RelatedId == currentUser.Id));
if (existing != null) return BadRequest("Relationship already exists.");
try
{