post reactions
This commit is contained in:
parent
d1687f276b
commit
8e8e4e2258
10 changed files with 124 additions and 8 deletions
|
@ -0,0 +1,3 @@
|
|||
namespace Femto.Api.Controllers.Posts.Dto;
|
||||
|
||||
public record AddPostReactionRequest(string Emoji);
|
|
@ -0,0 +1,3 @@
|
|||
namespace Femto.Api.Controllers.Posts.Dto;
|
||||
|
||||
public record DeletePostReactionRequest(string Emoji);
|
|
@ -1,6 +1,8 @@
|
|||
using Femto.Api.Controllers.Posts.Dto;
|
||||
using Femto.Common;
|
||||
using Femto.Modules.Blog.Application;
|
||||
using Femto.Modules.Blog.Application.Commands.AddPostReaction;
|
||||
using Femto.Modules.Blog.Application.Commands.ClearPostReaction;
|
||||
using Femto.Modules.Blog.Application.Commands.CreatePost;
|
||||
using Femto.Modules.Blog.Application.Commands.DeletePost;
|
||||
using Femto.Modules.Blog.Application.Queries.GetPosts;
|
||||
|
@ -95,4 +97,27 @@ public class PostsController(IBlogModule blogModule, ICurrentUserContext current
|
|||
cancellationToken
|
||||
);
|
||||
}
|
||||
|
||||
[HttpPost("{postId}/reactions")]
|
||||
[Authorize]
|
||||
public async Task<ActionResult> AddPostReaction(Guid postId, [FromBody] AddPostReactionRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var currentUser = currentUserContext.CurrentUser!;
|
||||
|
||||
await blogModule.Command(new AddPostReactionCommand(postId, request.Emoji, currentUser.Id), cancellationToken);
|
||||
|
||||
return this.Ok();
|
||||
}
|
||||
|
||||
[HttpDelete("{postId}/reactions")]
|
||||
[Authorize]
|
||||
public async Task<ActionResult> DeletePostReaction(Guid postId, [FromBody] DeletePostReactionRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var currentUser = currentUserContext.CurrentUser!;
|
||||
|
||||
await blogModule.Command(new ClearPostReactionCommand(postId, request.Emoji, currentUser.Id), cancellationToken);
|
||||
|
||||
return this.Ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue