🐛 Fix list replies need non-exists alias
This commit is contained in:
parent
dda0687b1a
commit
fba515fc70
@ -35,7 +35,7 @@ func MapAPIs(app *fiber.App, baseURL string) {
|
|||||||
posts.Post("/:postId/react", reactPost)
|
posts.Post("/:postId/react", reactPost)
|
||||||
posts.Delete("/:postId", deletePost)
|
posts.Delete("/:postId", deletePost)
|
||||||
|
|
||||||
posts.Get("/:post/replies", listPostReplies)
|
posts.Get("/:postId/replies", listPostReplies)
|
||||||
}
|
}
|
||||||
|
|
||||||
api.Get("/categories", listCategories)
|
api.Get("/categories", listCategories)
|
||||||
|
@ -14,7 +14,7 @@ func listPostReplies(c *fiber.Ctx) error {
|
|||||||
|
|
||||||
tx := database.C
|
tx := database.C
|
||||||
var post models.Post
|
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))
|
return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("unable to find post: %v", err))
|
||||||
} else {
|
} else {
|
||||||
tx = services.FilterPostReply(tx, post.ID)
|
tx = services.FilterPostReply(tx, post.ID)
|
||||||
|
Loading…
Reference in New Issue
Block a user