comments
This commit is contained in:
parent
cbf67bf5f1
commit
ce3888f1ab
15 changed files with 162 additions and 21 deletions
|
@ -1,6 +1,7 @@
|
|||
using Femto.Api.Controllers.Posts.Dto;
|
||||
using Femto.Common;
|
||||
using Femto.Modules.Blog.Application;
|
||||
using Femto.Modules.Blog.Application.Commands.AddPostComment;
|
||||
using Femto.Modules.Blog.Application.Commands.AddPostReaction;
|
||||
using Femto.Modules.Blog.Application.Commands.ClearPostReaction;
|
||||
using Femto.Modules.Blog.Application.Commands.CreatePost;
|
||||
|
@ -13,7 +14,7 @@ namespace Femto.Api.Controllers.Posts;
|
|||
|
||||
[ApiController]
|
||||
[Route("posts")]
|
||||
public class PostsController(IBlogModule blogModule, ICurrentUserContext currentUserContext)
|
||||
public class PostsController(IBlogModule blogModule, ICurrentUserContext currentUserContext, IAuthorizationService auth)
|
||||
: ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
|
@ -131,4 +132,23 @@ public class PostsController(IBlogModule blogModule, ICurrentUserContext current
|
|||
|
||||
return this.Ok();
|
||||
}
|
||||
|
||||
[HttpPost("{postId}/comments")]
|
||||
[Authorize]
|
||||
public async Task<ActionResult> AddPostComment(
|
||||
Guid postId,
|
||||
[FromBody] AddPostCommentRequest request,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
if (currentUserContext.CurrentUser?.Id != request.AuthorId)
|
||||
return this.BadRequest();
|
||||
|
||||
await blogModule.Command(
|
||||
new AddPostCommentCommand(postId, request.AuthorId, request.Content),
|
||||
cancellationToken
|
||||
);
|
||||
|
||||
return this.Ok();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue