From 78d624697c526784badf0e508041bbc74132703c Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Fri, 31 Jan 2025 18:13:42 +0800 Subject: [PATCH] :bug: Bug fixes --- pkg/internal/http/api/index.go | 2 +- pkg/internal/http/api/notify_api.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/internal/http/api/index.go b/pkg/internal/http/api/index.go index 8d9b0db..138e1bf 100644 --- a/pkg/internal/http/api/index.go +++ b/pkg/internal/http/api/index.go @@ -147,7 +147,7 @@ func MapAPIs(app *fiber.App, baseURL string) { developers := api.Group("/dev").Name("Developers API") { - developers.Post("/notify", notifyUser) + developers.Post("/notify/:user", notifyUser) developers.Post("/notify/all", notifyAllUser) bots := developers.Group("/bots").Name("Bots") diff --git a/pkg/internal/http/api/notify_api.go b/pkg/internal/http/api/notify_api.go index 6d2c912..ec7490f 100644 --- a/pkg/internal/http/api/notify_api.go +++ b/pkg/internal/http/api/notify_api.go @@ -25,7 +25,6 @@ func notifyUser(c *fiber.Ctx) error { Metadata map[string]any `json:"metadata"` Priority int `json:"priority"` IsRealtime bool `json:"is_realtime"` - UserID uint `json:"user_id" validate:"required"` } if err := exts.BindAndValidate(c, &data); err != nil { @@ -37,8 +36,10 @@ func notifyUser(c *fiber.Ctx) error { return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("unable to get client: %v", err)) } + userId, _ := c.ParamsInt("user") + var target models.Account - if target, err = services.GetAccount(data.UserID); err != nil { + if target, err = services.GetAccount(uint(userId)); err != nil { return fiber.NewError(fiber.StatusNotFound, err.Error()) }