diff --git a/internal/api/msg.go b/internal/api/msg.go index 3d6d4bc5d..ad89742af 100644 --- a/internal/api/msg.go +++ b/internal/api/msg.go @@ -167,9 +167,15 @@ func (m *MessageApi) DeleteMsgPhysical(c *gin.Context) { func (m *MessageApi) getSendMsgReq(c *gin.Context, req apistruct.SendMsg) (sendMsgReq *msg.SendMsgReq, err error) { var data interface{} + log.ZDebug(c, "getSendMsgReq", "req", req.Content) switch req.ContentType { case constant.Text: - data = apistruct.TextElem{} + text, ok := req.Content["content"].(string) + if !ok { + return nil, errs.ErrArgs.WithDetail("text is not string") + } + data = apistruct.TextContentElem{Content: text} + log.ZDebug(c, "getSendMsgReq", "data", data) case constant.Picture: data = apistruct.PictureElem{} case constant.Voice: @@ -195,7 +201,7 @@ func (m *MessageApi) getSendMsgReq(c *gin.Context, req apistruct.SendMsg) (sendM if err := mapstructure.WeakDecode(req.Content, &data); err != nil { return nil, err } - log.ZDebug(c, "getSendMsgReq", "data", data) + log.ZDebug(c, "getSendMsgReq", "req", req.Content) if err := m.validate.Struct(data); err != nil { return nil, err } diff --git a/pkg/apistruct/msg.go b/pkg/apistruct/msg.go index a0c5e1429..d31752f38 100644 --- a/pkg/apistruct/msg.go +++ b/pkg/apistruct/msg.go @@ -76,6 +76,10 @@ type TextElem struct { Text string `mapstructure:"text" validate:"required"` } +type TextContentElem struct { + Content string `json:"content" validate:"required"` +} + type RevokeElem struct { RevokeMsgClientID string `mapstructure:"revokeMsgClientID" validate:"required"` }