🐛 Fix post service grpc

This commit is contained in:
2025-10-26 03:41:59 +08:00
parent f65a7360e2
commit cdfc3f6571
2 changed files with 3 additions and 7 deletions

View File

@@ -73,7 +73,7 @@ public class SnPost : ModelBase, IIdentifiedResource, IActivity
public Guid PublisherId { get; set; }
public SnPublisher Publisher { get; set; } = null!;
public List<SnPostAward> Awards { get; set; } = null!;
public List<SnPostAward> Awards { get; set; } = [];
[JsonIgnore] public List<SnPostReaction> Reactions { get; set; } = [];
public List<SnPostTag> Tags { get; set; } = [];
public List<SnPostCategory> Categories { get; set; } = [];
@@ -174,7 +174,7 @@ public class SnPost : ModelBase, IIdentifiedResource, IActivity
}
proto.Attachments.AddRange(Attachments.Select(a => a.ToProtoValue()));
proto.Awards.AddRange(Awards.Select(a => a.ToProto()));
proto.Awards.AddRange(Awards.Select(a => a.ToProtoValue()));
proto.Reactions.AddRange(Reactions.Select(r => r.ToProtoValue()));
proto.Tags.AddRange(Tags.Select(t => t.ToProtoValue()));
proto.Categories.AddRange(Categories.Select(c => c.ToProtoValue()));
@@ -382,7 +382,7 @@ public class SnPostAward : ModelBase
[JsonIgnore] public SnPost Post { get; set; } = null!;
public Guid AccountId { get; set; }
public PostAward ToProto()
public PostAward ToProtoValue()
{
var proto = new PostAward
{
@@ -395,9 +395,7 @@ public class SnPostAward : ModelBase
UpdatedAt = Timestamp.FromDateTimeOffset(UpdatedAt.ToDateTimeOffset())
};
if (Message != null)
{
proto.Message = Message;
}
return proto;
}
}

View File

@@ -67,9 +67,7 @@ public class PostServiceGrpc(AppDatabase db, PostService ps) : Shared.Proto.Post
.Include(p => p.Categories)
.Include(p => p.RepliedPost)
.Include(p => p.ForwardedPost)
.Include(p => p.Attachments)
.Include(p => p.Awards)
.Include(p => p.Reactions)
.Include(p => p.FeaturedRecords)
.Where(p => p.DeletedAt == null) // Only active posts
.AsQueryable();