refactor post reactions
This commit is contained in:
parent
2519fc77d2
commit
5379d29c5f
13 changed files with 129 additions and 97 deletions
3
Femto.Api/Controllers/Posts/Dto/GetPostResponse.cs
Normal file
3
Femto.Api/Controllers/Posts/Dto/GetPostResponse.cs
Normal file
|
@ -0,0 +1,3 @@
|
|||
namespace Femto.Api.Controllers.Posts.Dto;
|
||||
|
||||
public record GetPostResponse(PostDto Post);
|
|
@ -3,4 +3,4 @@ using JetBrains.Annotations;
|
|||
namespace Femto.Api.Controllers.Posts.Dto;
|
||||
|
||||
[PublicAPI]
|
||||
public record LoadPostsResponse(IEnumerable<PostDto> Posts, Guid? Next);
|
||||
public record LoadPostsResponse(IEnumerable<PostDto> Posts);
|
|
@ -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
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
namespace Femto.Api.Controllers.Posts.Dto;
|
||||
|
||||
public record PostReactionDto(string Emoji, int Count, bool DidReact);
|
||||
public record PostReactionDto(string Emoji, string AuthorName, DateTimeOffset ReactedOn);
|
Loading…
Add table
Add a link
Reference in a new issue