diff --git a/DysonNetwork.Sphere/Post/PostActionController.cs b/DysonNetwork.Sphere/Post/PostActionController.cs index f7c1ffa..88cfee1 100644 --- a/DysonNetwork.Sphere/Post/PostActionController.cs +++ b/DysonNetwork.Sphere/Post/PostActionController.cs @@ -51,7 +51,7 @@ public class PostActionController( [MaxLength(16)] public List? Tags { get; set; } [MaxLength(8)] public List? Categories { get; set; } [MaxLength(32)] public List? Attachments { get; set; } - + public Dictionary? Meta { get; set; } public Instant? PublishedAt { get; set; } public Guid? RepliedPostId { get; set; } @@ -185,7 +185,7 @@ public class PostActionController( { FundId = request.FundId.Value.ToString() }); - + // Check if the fund was created by the current user if (fundResponse.CreatorAccountId != currentUser.Id) return BadRequest("You can only share funds that you created."); @@ -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 }) @@ -574,7 +576,7 @@ public class PostActionController( return BadRequest("Content is required."); if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); - + if (!string.IsNullOrWhiteSpace(request.ThumbnailId) && request.Type != PostType.Article) return BadRequest("Thumbnail only supported in article."); if (!string.IsNullOrWhiteSpace(request.ThumbnailId) && @@ -675,7 +677,7 @@ public class PostActionController( { FundId = request.FundId.Value.ToString() }); - + // Check if the fund was created by the current user if (fundResponse.CreatorAccountId != currentUser.Id) return BadRequest("You can only share funds that you created."); @@ -746,7 +748,7 @@ public class PostActionController( { post.RealmId = null; } - + try { post = await ps.UpdatePostAsync( @@ -828,4 +830,4 @@ public class PostActionController( return NoContent(); } -} +} \ No newline at end of file diff --git a/DysonNetwork.Sphere/Post/PostController.cs b/DysonNetwork.Sphere/Post/PostController.cs index 6201a4d..252e4a8 100644 --- a/DysonNetwork.Sphere/Post/PostController.cs +++ b/DysonNetwork.Sphere/Post/PostController.cs @@ -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(); } diff --git a/DysonNetwork.Sphere/Timeline/TimelineService.cs b/DysonNetwork.Sphere/Timeline/TimelineService.cs index e72f0f2..f5f4323 100644 --- a/DysonNetwork.Sphere/Timeline/TimelineService.cs +++ b/DysonNetwork.Sphere/Timeline/TimelineService.cs @@ -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));