wip
This commit is contained in:
parent
def7767b94
commit
8ad4302ec8
13 changed files with 3902 additions and 4 deletions
|
@ -3,4 +3,4 @@ using JetBrains.Annotations;
|
|||
namespace Femto.Api.Controllers.Posts.Dto;
|
||||
|
||||
[PublicAPI]
|
||||
public record GetAllPublicPostsResponse(IEnumerable<PostDto> Posts, Guid? Next);
|
||||
public record LoadPostsResponse(IEnumerable<PostDto> Posts, Guid? Next);
|
|
@ -8,5 +8,6 @@ public record PostDto(
|
|||
Guid PostId,
|
||||
string Content,
|
||||
IEnumerable<PostMediaDto> Media,
|
||||
IEnumerable<PostReactionDto> Reactions,
|
||||
DateTimeOffset CreatedAt
|
||||
);
|
3
Femto.Api/Controllers/Posts/Dto/PostReactionDto.cs
Normal file
3
Femto.Api/Controllers/Posts/Dto/PostReactionDto.cs
Normal file
|
@ -0,0 +1,3 @@
|
|||
namespace Femto.Api.Controllers.Posts.Dto;
|
||||
|
||||
public record PostReactionDto(Guid ReactionId, string Emoji, int Count, bool DidReact);
|
|
@ -14,7 +14,7 @@ namespace Femto.Api.Controllers.Posts;
|
|||
public class PostsController(IBlogModule blogModule, ICurrentUserContext currentUserContext) : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<GetAllPublicPostsResponse>> LoadPosts(
|
||||
public async Task<ActionResult<LoadPostsResponse>> LoadPosts(
|
||||
[FromQuery] GetPublicPostsSearchParams searchParams,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
|
@ -30,12 +30,13 @@ public class PostsController(IBlogModule blogModule, ICurrentUserContext current
|
|||
cancellationToken
|
||||
);
|
||||
|
||||
return new GetAllPublicPostsResponse(
|
||||
return new LoadPostsResponse(
|
||||
res.Posts.Select(p => new PostDto(
|
||||
new PostAuthorDto(p.Author.AuthorId, p.Author.Username),
|
||||
p.PostId,
|
||||
p.Text,
|
||||
p.Media.Select(m => new PostMediaDto(m.Url, m.Width, m.Height)),
|
||||
p.Reactions?.Select(r => new PostReactionDto(r.ReactionId, r.Emoji, r.Count, r.DidReact)),
|
||||
p.CreatedAt
|
||||
)),
|
||||
res.Next
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue