From 687614d3f432ab5629b97b35d37f76e25349a898 Mon Sep 17 00:00:00 2001 From: pluto <2631223275@qq.com> Date: Thu, 31 Aug 2023 16:38:35 +0800 Subject: [PATCH] refactor:Optimization of text messages when accepting message req (#981) --- internal/api/msg.go | 7 +------ pkg/apistruct/msg.go | 5 +---- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/internal/api/msg.go b/internal/api/msg.go index 2bbae9765..726889d56 100644 --- a/internal/api/msg.go +++ b/internal/api/msg.go @@ -170,12 +170,7 @@ func (m *MessageApi) getSendMsgReq(c *gin.Context, req apistruct.SendMsg) (sendM log.ZDebug(c, "getSendMsgReq", "req", req.Content) switch req.ContentType { case constant.Text: - text, ok := req.Content["text"].(string) - if !ok { - return nil, errs.ErrArgs.WithDetail("text is not string") - } - data = apistruct.TextContentElem{Content: text} - log.ZDebug(c, "getSendMsgReq", "data", data) + data = apistruct.TextElem{} case constant.Picture: data = apistruct.PictureElem{} case constant.Voice: diff --git a/pkg/apistruct/msg.go b/pkg/apistruct/msg.go index d31752f38..12cf253a0 100644 --- a/pkg/apistruct/msg.go +++ b/pkg/apistruct/msg.go @@ -72,11 +72,8 @@ type CustomElem struct { Description string `mapstructure:"description"` Extension string `mapstructure:"extension"` } -type TextElem struct { - Text string `mapstructure:"text" validate:"required"` -} -type TextContentElem struct { +type TextElem struct { Content string `json:"content" validate:"required"` }