🐛 Trying to fix some bugs
This commit is contained in:
parent
973ebe6d6d
commit
390ac7e883
@ -21,12 +21,16 @@ import (
|
||||
)
|
||||
|
||||
func UniversalPostFilter(c *fiber.Ctx, tx *gorm.DB) (*gorm.DB, error) {
|
||||
tx = services.FilterPostDraft(tx)
|
||||
|
||||
if user, authenticated := c.Locals("user").(authm.Account); authenticated {
|
||||
tx = services.FilterPostWithUserContext(c, tx, &user)
|
||||
if c.QueryBool("noDraft", true) {
|
||||
tx = services.FilterPostDraft(tx)
|
||||
} else {
|
||||
tx = services.FilterPostDraftWithAuthor(database.C, user.ID)
|
||||
}
|
||||
} else {
|
||||
tx = services.FilterPostWithUserContext(c, tx, nil)
|
||||
tx = services.FilterPostDraft(tx)
|
||||
}
|
||||
|
||||
if c.QueryBool("noReply", true) {
|
||||
@ -70,16 +74,8 @@ func getPost(c *fiber.Ctx) error {
|
||||
|
||||
tx := database.C
|
||||
|
||||
if user, authenticated := c.Locals("user").(authm.Account); authenticated {
|
||||
tx = services.FilterPostDraftWithAuthor(database.C, user.ID)
|
||||
} else {
|
||||
tx = services.FilterPostDraft(database.C)
|
||||
}
|
||||
|
||||
if user, authenticated := c.Locals("user").(authm.Account); authenticated {
|
||||
tx = services.FilterPostWithUserContext(c, tx, &user)
|
||||
} else {
|
||||
tx = services.FilterPostWithUserContext(c, tx, nil)
|
||||
if tx, err = UniversalPostFilter(c, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if numericId, paramErr := strconv.Atoi(id); paramErr == nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user