Count post views

This commit is contained in:
2025-02-17 17:21:15 +08:00
parent 14c17eded8
commit 269e79ca58
11 changed files with 141 additions and 20 deletions

View File

@@ -28,7 +28,12 @@ func listPinnedPost(c *fiber.Ctx) error {
tx = tx.Where("publisher_id = ?", user.ID)
tx = tx.Where("pinned_at IS NOT NULL")
items, err := services.ListPost(tx, 100, 0, "published_at DESC")
var userId *uint
if user, authenticated := c.Locals("user").(authm.Account); authenticated {
userId = &user.ID
}
items, err := services.ListPost(tx, 100, 0, "published_at DESC", userId)
if err != nil {
return fiber.NewError(fiber.StatusBadRequest, err.Error())
}