diff --git a/DysonNetwork.Pass/Account/RelationshipController.cs b/DysonNetwork.Pass/Account/RelationshipController.cs index 3719bf8a..aa2a6222 100644 --- a/DysonNetwork.Pass/Account/RelationshipController.cs +++ b/DysonNetwork.Pass/Account/RelationshipController.cs @@ -1,4 +1,5 @@ using System.ComponentModel.DataAnnotations; +using DysonNetwork.Shared.Auth; using DysonNetwork.Shared.Models; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -274,4 +275,30 @@ public class RelationshipController(AppDatabase db, RelationshipService rls) : C return BadRequest(err.Message); } } + + public class InspectRelationshipResponse + { + public List Friends { get; set; } = []; + public List Blocked { get; set; } = []; + public List Pending { get; set; } = []; + } + + [HttpGet("inspect/{accountId:guid}")] + [Authorize] + [AskPermission("relationships.inspect")] + public async Task> InspectRelationship(Guid accountId) + { + var relationships = await db.AccountRelationships + .Where(r => r.AccountId == accountId) + .Include(r => r.Related) + .GroupBy(r => r.Status, r => r.Related) + .ToDictionaryAsync(r => r.Key, r => r); + + return Ok(new InspectRelationshipResponse + { + Friends = relationships.TryGetValue(RelationshipStatus.Friends, out var friends) ? friends.ToList() : [], + Blocked = relationships.TryGetValue(RelationshipStatus.Blocked, out var blocked) ? blocked.ToList() : [], + Pending = relationships.TryGetValue(RelationshipStatus.Pending, out var pending) ? pending.ToList() : [] + }); + } } \ No newline at end of file