refactor post reactions

This commit is contained in:
john 2025-08-10 18:12:16 +02:00
parent 2519fc77d2
commit 5379d29c5f
13 changed files with 129 additions and 97 deletions

View file

@ -11,4 +11,16 @@ public record PostDto(
IEnumerable<PostReactionDto> Reactions,
DateTimeOffset CreatedAt,
IEnumerable<string> PossibleReactions
);
)
{
public static PostDto FromModel(Modules.Blog.Application.Queries.GetPosts.Dto.PostDto post) =>
new(
new PostAuthorDto(post.Author.AuthorId, post.Author.Username),
post.PostId,
post.Text,
post.Media.Select(m => new PostMediaDto(m.Url, m.Width, m.Height)),
post.Reactions.Select(r => new PostReactionDto(r.Emoji, r.AuthorName, r.ReactedOn)),
post.CreatedAt,
post.PossibleReactions
);
}