🐛 Fix user cannot get draft posts

This commit is contained in:
2025-03-08 21:38:41 +08:00
parent dd5ce8074b
commit 5f5f2bd1a5
2 changed files with 21 additions and 1 deletions

View File

@ -68,7 +68,13 @@ func getPost(c *fiber.Ctx) error {
var item models.Post
var err error
tx := services.FilterPostDraft(database.C)
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)