👔 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")]
|
[HttpGet("requests")]
|
||||||
[Authorize]
|
[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();
|
if (HttpContext.Items["CurrentUser"] is not SnAccount currentUser) return Unauthorized();
|
||||||
|
|
||||||
var relationships = await db.AccountRelationships
|
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)
|
.Include(r => r.Related)
|
||||||
.ThenInclude(a => a.Profile)
|
.ThenInclude(a => a.Profile)
|
||||||
|
.Include(r => r.Account)
|
||||||
|
.ThenInclude(a => a.Profile)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
return relationships;
|
return relationships;
|
||||||
|
|||||||
Reference in New Issue
Block a user