From bf26e92241a006cc1bb905b4d4b2d2046df24eee Mon Sep 17 00:00:00 2001 From: luhaoling <2198702716@qq.com> Date: Wed, 17 Jan 2024 09:59:59 +0800 Subject: [PATCH] fix:solve json format error --- internal/api/msg.go | 9 +++++++++ pkg/common/http/http_client.go | 3 --- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/api/msg.go b/internal/api/msg.go index 88f25a425..9266dc8a8 100644 --- a/internal/api/msg.go +++ b/internal/api/msg.go @@ -461,6 +461,15 @@ func (m *MessageApi) CallbackExample(c *gin.Context) { } content := make(map[string]any, 1) + log.ZDebug(c, "CallbackExample content content content content content content content content", "content", req.Content) + str := &apistruct.TextElem{} + err = json.Unmarshal([]byte(req.Content), str) + if err != nil { + log.ZError(c, "CallbackExample unmarshal failed", err) + apiresp.GinError(c, errs.ErrInternalServer.WithDetail(err.Error()).Wrap()) + return + } + content["content"] = req.Content input := &apistruct.SendMsgReq{ RecvID: req.SendID, diff --git a/pkg/common/http/http_client.go b/pkg/common/http/http_client.go index fc04ec2a8..a80d1c9a4 100644 --- a/pkg/common/http/http_client.go +++ b/pkg/common/http/http_client.go @@ -69,9 +69,6 @@ func Post(ctx context.Context, url string, header map[string]string, data any, t return nil, err } - log.ZInfo(ctx, "CallbackExample", "jsonStraaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", jsonStr) - log.ZInfo(ctx, "CallbackExample", "jsonStr", string(jsonStr)) - req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewBuffer(jsonStr)) if err != nil { return nil, err