👔 Update the requests endpoint to show both sent / received friend requests

This commit is contained in:
2026-01-07 01:29:44 +08:00
parent cf736be61a
commit 1fc9c68d80

View File

@@ -38,14 +38,17 @@ public class RelationshipController(AppDatabase db, RelationshipService rls) : C
[HttpGet("requests")]
[Authorize]
public async Task<ActionResult<List<SnAccountRelationship>>> ListSentRequests()
public async Task<ActionResult<List<SnAccountRelationship>>> ListRelationshipRequests()
{
if (HttpContext.Items["CurrentUser"] is not SnAccount currentUser) return Unauthorized();
var relationships = await db.AccountRelationships
.Where(r => r.AccountId == currentUser.Id && r.Status == RelationshipStatus.Pending)
.Where(r => r.Status == RelationshipStatus.Pending)
.Where(r => r.AccountId == currentUser.Id || r.RelatedId == currentUser.Id)
.Include(r => r.Related)
.ThenInclude(a => a.Profile)
.Include(r => r.Account)
.ThenInclude(a => a.Profile)
.ToListAsync();
return relationships;