From cf736be61a9a2ebe86d615eb118803c6a48eda25 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 7 Jan 2026 01:04:11 +0800 Subject: [PATCH] :bug: Fix some relationship issues --- .../Account/RelationshipController.cs | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/DysonNetwork.Pass/Account/RelationshipController.cs b/DysonNetwork.Pass/Account/RelationshipController.cs index aa2a6222..bcd57830 100644 --- a/DysonNetwork.Pass/Account/RelationshipController.cs +++ b/DysonNetwork.Pass/Account/RelationshipController.cs @@ -22,25 +22,15 @@ public class RelationshipController(AppDatabase db, RelationshipService rls) : C var query = db.AccountRelationships.AsQueryable() .OrderByDescending(r => r.CreatedAt) - .Where(r => r.RelatedId == accountId); + .Where(r => r.AccountId == accountId); var totalCount = await query.CountAsync(); var relationships = await query .Include(r => r.Related) - .Include(r => r.Related.Profile) - .Include(r => r.Account) - .Include(r => r.Account.Profile) + .ThenInclude(a => a.Profile) .Skip(offset) .Take(take) .ToListAsync(); - var statuses = await db.AccountRelationships - .Where(r => r.AccountId == accountId) - .ToDictionaryAsync(r => r.RelatedId); - foreach (var relationship in relationships) - relationship.Status = statuses.TryGetValue(relationship.AccountId, out var status) - ? status.Status - : RelationshipStatus.Pending; - Response.Headers["X-Total"] = totalCount.ToString(); return relationships; @@ -55,9 +45,7 @@ public class RelationshipController(AppDatabase db, RelationshipService rls) : C var relationships = await db.AccountRelationships .Where(r => r.AccountId == currentUser.Id && r.Status == RelationshipStatus.Pending) .Include(r => r.Related) - .Include(r => r.Related.Profile) - .Include(r => r.Account) - .Include(r => r.Account.Profile) + .ThenInclude(a => a.Profile) .ToListAsync(); return relationships;