diff --git a/DysonNetwork.Sphere/Account/RelationshipController.cs b/DysonNetwork.Sphere/Account/RelationshipController.cs index 3ab1378..48a9ba7 100644 --- a/DysonNetwork.Sphere/Account/RelationshipController.cs +++ b/DysonNetwork.Sphere/Account/RelationshipController.cs @@ -107,6 +107,11 @@ public class RelationshipController(AppDatabase db, RelationshipService rels) : var relatedUser = await db.Accounts.FindAsync(userId); if (relatedUser is null) return NotFound("Account was not found."); + + var existing = await db.AccountRelationships.FirstOrDefaultAsync(r => + (r.AccountId == currentUser.Id && r.RelatedId == userId) || + (r.AccountId == userId && r.RelatedId == currentUser.Id)); + if (existing != null) return BadRequest("Relationship already exists."); try { diff --git a/DysonNetwork.Sphere/Post/PostService.cs b/DysonNetwork.Sphere/Post/PostService.cs index 942bb61..1845b34 100644 --- a/DysonNetwork.Sphere/Post/PostService.cs +++ b/DysonNetwork.Sphere/Post/PostService.cs @@ -263,7 +263,7 @@ public static class PostQueryExtensions .Where(e => e.Visibility == PostVisibility.Public); return source - .Where(e => e.PublishedAt != null && now >= e.PublishedAt && e.Publisher.AccountId == currentUser.Id) + .Where(e => (e.PublishedAt != null && now >= e.PublishedAt) || e.Publisher.AccountId == currentUser.Id) .Where(e => e.Visibility != PostVisibility.Private || e.Publisher.AccountId == currentUser.Id) .Where(e => e.Visibility != PostVisibility.Friends || (e.Publisher.AccountId != null && userFriends.Contains(e.Publisher.AccountId.Value)) ||