👔 Update the requests endpoint to show both sent / received friend requests
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user