From 37aa69e6ca13f8876f7b1f1ff6878a0fd026ea86 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Fri, 26 Jul 2024 16:15:08 +0800 Subject: [PATCH] :bug: Fix querystring naming issue --- pkg/internal/server/api/posts_api.go | 4 ++-- pkg/internal/server/api/replies_api.go | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/internal/server/api/posts_api.go b/pkg/internal/server/api/posts_api.go index 0da3146..72d08a0 100644 --- a/pkg/internal/server/api/posts_api.go +++ b/pkg/internal/server/api/posts_api.go @@ -46,9 +46,9 @@ func listPost(c *fiber.Ctx) error { } } - if len(c.Query("authorId")) > 0 { + if len(c.Query("author")) > 0 { var author models.Account - if err := database.C.Where(&models.Account{Name: c.Query("authorId")}).First(&author).Error; err != nil { + if err := database.C.Where(&models.Account{Name: c.Query("author")}).First(&author).Error; err != nil { return fiber.NewError(fiber.StatusNotFound, err.Error()) } tx = tx.Where("author_id = ?", author.ID) diff --git a/pkg/internal/server/api/replies_api.go b/pkg/internal/server/api/replies_api.go index d5cc115..7595646 100644 --- a/pkg/internal/server/api/replies_api.go +++ b/pkg/internal/server/api/replies_api.go @@ -2,6 +2,7 @@ package api import ( "fmt" + "git.solsynth.dev/hydrogen/interactive/pkg/internal/database" "git.solsynth.dev/hydrogen/interactive/pkg/internal/models" "git.solsynth.dev/hydrogen/interactive/pkg/internal/services" @@ -20,9 +21,9 @@ func listPostReplies(c *fiber.Ctx) error { tx = services.FilterPostReply(tx, post.ID) } - if len(c.Query("authorId")) > 0 { + if len(c.Query("author")) > 0 { var author models.Account - if err := database.C.Where(&models.Account{Name: c.Query("authorId")}).First(&author).Error; err != nil { + if err := database.C.Where(&models.Account{Name: c.Query("author")}).First(&author).Error; err != nil { return fiber.NewError(fiber.StatusNotFound, err.Error()) } tx = tx.Where("author_id = ?", author.ID)