🐛 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) {
|
func UniversalPostFilter(c *fiber.Ctx, tx *gorm.DB) (*gorm.DB, error) {
|
||||||
tx = services.FilterPostDraft(tx)
|
|
||||||
|
|
||||||
if user, authenticated := c.Locals("user").(authm.Account); authenticated {
|
if user, authenticated := c.Locals("user").(authm.Account); authenticated {
|
||||||
tx = services.FilterPostWithUserContext(c, tx, &user)
|
tx = services.FilterPostWithUserContext(c, tx, &user)
|
||||||
|
if c.QueryBool("noDraft", true) {
|
||||||
|
tx = services.FilterPostDraft(tx)
|
||||||
|
} else {
|
||||||
|
tx = services.FilterPostDraftWithAuthor(database.C, user.ID)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
tx = services.FilterPostWithUserContext(c, tx, nil)
|
tx = services.FilterPostWithUserContext(c, tx, nil)
|
||||||
|
tx = services.FilterPostDraft(tx)
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.QueryBool("noReply", true) {
|
if c.QueryBool("noReply", true) {
|
||||||
@ -70,16 +74,8 @@ func getPost(c *fiber.Ctx) error {
|
|||||||
|
|
||||||
tx := database.C
|
tx := database.C
|
||||||
|
|
||||||
if user, authenticated := c.Locals("user").(authm.Account); authenticated {
|
if tx, err = UniversalPostFilter(c, tx); err != nil {
|
||||||
tx = services.FilterPostDraftWithAuthor(database.C, user.ID)
|
return err
|
||||||
} 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 numericId, paramErr := strconv.Atoi(id); paramErr == nil {
|
if numericId, paramErr := strconv.Atoi(id); paramErr == nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user