fix: send text message by api doesn't work. (#954)

* send msg

* send_msg

* fix: text

* text
pull/957/head v3.2.2-alpha.0
WangchuXiao 1 year ago committed by GitHub
parent 303162f8a5
commit 31ae8271e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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
}

@ -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"`
}

Loading…
Cancel
Save