Compare commits
2 Commits
69e9a108ef
...
ac30cb5e4d
Author | SHA1 | Date | |
---|---|---|---|
ac30cb5e4d | |||
d189c5a8d8 |
@ -67,6 +67,7 @@ func MapControllers(app *fiber.App, baseURL string) {
|
|||||||
posts.Post("/:postId/flag", createFlag)
|
posts.Post("/:postId/flag", createFlag)
|
||||||
posts.Post("/:postId/react", reactPost)
|
posts.Post("/:postId/react", reactPost)
|
||||||
posts.Post("/:postId/pin", pinPost)
|
posts.Post("/:postId/pin", pinPost)
|
||||||
|
posts.Post("/:postId/uncollapse", uncollapsePost)
|
||||||
posts.Delete("/:postId", deletePost)
|
posts.Delete("/:postId", deletePost)
|
||||||
|
|
||||||
posts.Get("/:postId/replies", listPostReplies)
|
posts.Get("/:postId/replies", listPostReplies)
|
||||||
|
@ -372,3 +372,17 @@ func pinPost(c *fiber.Ctx) error {
|
|||||||
return c.SendStatus(fiber.StatusNoContent)
|
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)
|
||||||
|
}
|
||||||
|
@ -26,6 +26,10 @@ func NewFlag(post models.Post, account uint) (models.PostFlag, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func FlagCalculateCollapseStatus(post models.Post) error {
|
func FlagCalculateCollapseStatus(post models.Post) error {
|
||||||
|
if post.TotalViews <= 2 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
collapseLimit := 0.5
|
collapseLimit := 0.5
|
||||||
|
|
||||||
var flagCount int64
|
var flagCount int64
|
||||||
|
@ -48,9 +48,6 @@ func UniversalPostFilter(c *fiber.Ctx, tx *gorm.DB, cfg ...UniversalPostFilterCo
|
|||||||
if c.QueryBool("noReply", true) && !config.ShowReply {
|
if c.QueryBool("noReply", true) && !config.ShowReply {
|
||||||
tx = FilterPostReply(tx)
|
tx = FilterPostReply(tx)
|
||||||
}
|
}
|
||||||
if c.QueryBool("noCollapse", true) && !config.ShowCollapsed {
|
|
||||||
tx = tx.Where("is_collapsed = ? OR is_collapsed IS NULL", false)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(c.Query("author")) > 0 {
|
if len(c.Query("author")) > 0 {
|
||||||
var author models.Publisher
|
var author models.Publisher
|
||||||
|
Loading…
x
Reference in New Issue
Block a user