Community mod able to uncollapse post

This commit is contained in:
LittleSheep 2025-04-05 12:17:48 +08:00
parent d189c5a8d8
commit ac30cb5e4d
2 changed files with 15 additions and 0 deletions

View File

@ -67,6 +67,7 @@ func MapControllers(app *fiber.App, baseURL string) {
posts.Post("/:postId/flag", createFlag)
posts.Post("/:postId/react", reactPost)
posts.Post("/:postId/pin", pinPost)
posts.Post("/:postId/uncollapse", uncollapsePost)
posts.Delete("/:postId", deletePost)
posts.Get("/:postId/replies", listPostReplies)

View File

@ -372,3 +372,17 @@ func pinPost(c *fiber.Ctx) error {
return c.SendStatus(fiber.StatusNoContent)
}
}
func uncollapsePost(c *fiber.Ctx) error {
id, _ := c.ParamsInt("postId", 0)
if err := sec.EnsureGrantedPerm(c, "UncollapsePosts", true); err != nil {
return err
}
if err := database.C.Model(&models.Post{}).Where("id = ?", id).Update("is_collapsed", false).Error; err != nil {
return fiber.NewError(fiber.StatusBadRequest, err.Error())
}
return c.SendStatus(fiber.StatusOK)
}