mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
fix: send text message by api doesn't work. (#954)
* send msg * send_msg * fix: text * text
This commit is contained in:
parent
303162f8a5
commit
31ae8271e7
@ -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) {
|
func (m *MessageApi) getSendMsgReq(c *gin.Context, req apistruct.SendMsg) (sendMsgReq *msg.SendMsgReq, err error) {
|
||||||
var data interface{}
|
var data interface{}
|
||||||
|
log.ZDebug(c, "getSendMsgReq", "req", req.Content)
|
||||||
switch req.ContentType {
|
switch req.ContentType {
|
||||||
case constant.Text:
|
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:
|
case constant.Picture:
|
||||||
data = apistruct.PictureElem{}
|
data = apistruct.PictureElem{}
|
||||||
case constant.Voice:
|
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 {
|
if err := mapstructure.WeakDecode(req.Content, &data); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
log.ZDebug(c, "getSendMsgReq", "data", data)
|
log.ZDebug(c, "getSendMsgReq", "req", req.Content)
|
||||||
if err := m.validate.Struct(data); err != nil {
|
if err := m.validate.Struct(data); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,10 @@ type TextElem struct {
|
|||||||
Text string `mapstructure:"text" validate:"required"`
|
Text string `mapstructure:"text" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TextContentElem struct {
|
||||||
|
Content string `json:"content" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
type RevokeElem struct {
|
type RevokeElem struct {
|
||||||
RevokeMsgClientID string `mapstructure:"revokeMsgClientID" validate:"required"`
|
RevokeMsgClientID string `mapstructure:"revokeMsgClientID" validate:"required"`
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user