Able to get post reactions list

This commit is contained in:
2025-07-31 20:51:28 +08:00
parent 4cfd4387b6
commit b3ed98322b

View File

@@ -151,6 +151,30 @@ public class PostController(
return Ok(posts);
}
[HttpGet("{id:guid}/reactions")]
public async Task<ActionResult<List<PostReaction>>> GetReactions(
Guid id,
[FromQuery] string? symbol = null,
[FromQuery] int offset = 0,
[FromQuery] int take = 20
)
{
var query = db.PostReactions
.Where(e => e.PostId == id);
if (symbol is not null) query = query.Where(e => e.Symbol == symbol);
var totalCount = await query.CountAsync();
Response.Headers.Append("X-Total", totalCount.ToString());
var reactions = await query
.OrderBy(r => r.Symbol)
.ThenByDescending(r => r.CreatedAt)
.Take(take)
.Skip(offset)
.ToListAsync();
return Ok(reactions);
}
[HttpGet("{id:guid}/replies/featured")]
public async Task<ActionResult<Post>> GetFeaturedReply(Guid id)
{