🐛 Use new isRelated to query relationship to avoid issues

This commit is contained in:
2026-01-01 13:53:48 +08:00
parent 8c19bd6a73
commit c28d7bedd7
3 changed files with 21 additions and 20 deletions

View File

@@ -286,7 +286,7 @@ public class PostActionController(
return Unauthorized();
var friendsResponse = await accounts.ListFriendsAsync(
new ListRelationshipSimpleRequest { AccountId = currentUser.Id.ToString() }
new ListRelationshipSimpleRequest { RelatedId = currentUser.Id }
);
var userFriends = friendsResponse.AccountsId.Select(Guid.Parse).ToList();
var userPublishers = await pub.GetUserPublishers(Guid.Parse(currentUser.Id));
@@ -305,7 +305,7 @@ public class PostActionController(
var accountId = Guid.Parse(currentUser.Id);
var isSelfReact =
post.Publisher.AccountId is not null && post.Publisher.AccountId == accountId;
post.Publisher?.AccountId is not null && post.Publisher.AccountId == accountId;
var isExistingReaction = await db.PostReactions.AnyAsync(r =>
r.PostId == post.Id && r.Symbol == request.Symbol && r.AccountId == accountId
@@ -454,7 +454,8 @@ public class PostActionController(
return NotFound();
var accountId = Guid.Parse(currentUser.Id);
if (post.PublisherId == null || !await pub.IsMemberWithRole(post.PublisherId.Value, accountId, PublisherMemberRole.Editor))
if (post.PublisherId == null ||
!await pub.IsMemberWithRole(post.PublisherId.Value, accountId, PublisherMemberRole.Editor))
return StatusCode(403, "You are not an editor of this publisher");
if (request.Mode == Shared.Models.PostPinMode.RealmPage && post.RealmId != null)
@@ -518,7 +519,8 @@ public class PostActionController(
return NotFound();
var accountId = Guid.Parse(currentUser.Id);
if (post.PublisherId == null || !await pub.IsMemberWithRole(post.PublisherId.Value, accountId, PublisherMemberRole.Editor))
if (post.PublisherId == null ||
!await pub.IsMemberWithRole(post.PublisherId.Value, accountId, PublisherMemberRole.Editor))
return StatusCode(403, "You are not an editor of this publisher");
if (post is { PinMode: Shared.Models.PostPinMode.RealmPage, RealmId: not null })

View File

@@ -80,7 +80,7 @@ public class PostController(
if (currentUser != null)
{
var friendsResponse = await accounts.ListFriendsAsync(
new ListRelationshipSimpleRequest { AccountId = currentUser.Id }
new ListRelationshipSimpleRequest { RelatedId = currentUser.Id }
);
userFriends = friendsResponse.AccountsId.Select(Guid.Parse).ToList();
}
@@ -239,7 +239,7 @@ public class PostController(
if (currentUser != null)
{
var friendsResponse = await accounts.ListFriendsAsync(
new ListRelationshipSimpleRequest { AccountId = currentUser.Id }
new ListRelationshipSimpleRequest { RelatedId = currentUser.Id }
);
userFriends = friendsResponse.AccountsId.Select(Guid.Parse).ToList();
}
@@ -276,7 +276,7 @@ public class PostController(
if (currentUser != null)
{
var friendsResponse = await accounts.ListFriendsAsync(
new ListRelationshipSimpleRequest { AccountId = currentUser.Id }
new ListRelationshipSimpleRequest { RelatedId = currentUser.Id }
);
userFriends = friendsResponse.AccountsId.Select(Guid.Parse).ToList();
}
@@ -354,7 +354,7 @@ public class PostController(
if (currentUser != null)
{
var friendsResponse = await accounts.ListFriendsAsync(
new ListRelationshipSimpleRequest { AccountId = currentUser.Id }
new ListRelationshipSimpleRequest { RelatedId = currentUser.Id }
);
userFriends = friendsResponse.AccountsId.Select(Guid.Parse).ToList();
}
@@ -387,7 +387,7 @@ public class PostController(
if (currentUser != null)
{
var friendsResponse = await accounts.ListFriendsAsync(
new ListRelationshipSimpleRequest { AccountId = currentUser.Id }
new ListRelationshipSimpleRequest { RelatedId = currentUser.Id }
);
userFriends = friendsResponse.AccountsId.Select(Guid.Parse).ToList();
}
@@ -396,9 +396,8 @@ public class PostController(
? []
: await pub.GetUserPublishers(Guid.Parse(currentUser.Id));
var now = SystemClock.Instance.GetCurrentInstant();
var posts = await db
.Posts.Where(e =>
var posts = await db.Posts
.Where(e =>
e.RepliedPostId == id && e.PinMode == Shared.Models.PostPinMode.ReplyPage
)
.OrderByDescending(p => p.CreatedAt)
@@ -423,7 +422,7 @@ public class PostController(
if (currentUser != null)
{
var friendsResponse = await accounts.ListFriendsAsync(
new ListRelationshipSimpleRequest { AccountId = currentUser.Id }
new ListRelationshipSimpleRequest { RelatedId = currentUser.Id }
);
userFriends = friendsResponse.AccountsId.Select(Guid.Parse).ToList();
}

View File

@@ -85,7 +85,7 @@ public class TimelineService(
// Get user's friends and publishers
var friendsResponse = await accounts.ListFriendsAsync(
new ListRelationshipSimpleRequest { AccountId = currentUser.Id }
new ListRelationshipSimpleRequest { RelatedId = currentUser.Id }
);
var userFriends = friendsResponse.AccountsId.Select(Guid.Parse).ToList();
var userPublishers = await pub.GetUserPublishers(Guid.Parse(currentUser.Id));