From 41af202623e4404c90105b90e1c24d3e7f4712c0 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Mon, 16 Sep 2024 21:28:48 +0800 Subject: [PATCH] :bug: Fix get post will ignore visibility --- pkg/internal/server/api/posts_api.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/internal/server/api/posts_api.go b/pkg/internal/server/api/posts_api.go index d1beae0..05246c0 100644 --- a/pkg/internal/server/api/posts_api.go +++ b/pkg/internal/server/api/posts_api.go @@ -22,6 +22,13 @@ func getPost(c *fiber.Ctx) error { var err error tx := services.FilterPostDraft(database.C) + + if user, authenticated := c.Locals("user").(models.Account); authenticated { + tx = services.FilterPostWithUserContext(tx, &user) + } else { + tx = services.FilterPostWithUserContext(tx, nil) + } + if numericId, paramErr := strconv.Atoi(id); paramErr == nil { item, err = services.GetPost(tx, uint(numericId)) } else {