🐛 Fix list replies need non-exists alias

This commit is contained in:
LittleSheep 2024-07-23 17:59:11 +08:00
parent dda0687b1a
commit fba515fc70
2 changed files with 2 additions and 2 deletions

View File

@ -35,7 +35,7 @@ func MapAPIs(app *fiber.App, baseURL string) {
posts.Post("/:postId/react", reactPost)
posts.Delete("/:postId", deletePost)
posts.Get("/:post/replies", listPostReplies)
posts.Get("/:postId/replies", listPostReplies)
}
api.Get("/categories", listCategories)

View File

@ -14,7 +14,7 @@ func listPostReplies(c *fiber.Ctx) error {
tx := database.C
var post models.Post
if err := database.C.Where("alias = ?", c.Params("post")).First(&post).Error; err != nil {
if err := database.C.Where("id = ?", c.Params("postId")).First(&post).Error; err != nil {
return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("unable to find post: %v", err))
} else {
tx = services.FilterPostReply(tx, post.ID)