mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-17 11:39:14 +08:00
send msg
This commit is contained in:
parent
a22a0e5b52
commit
38896e1d6d
@ -15,6 +15,8 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/tools/mcontext"
|
"github.com/OpenIMSDK/tools/mcontext"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/go-playground/validator/v10"
|
"github.com/go-playground/validator/v10"
|
||||||
@ -167,9 +169,18 @@ 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["text"].(string)
|
||||||
|
if !ok {
|
||||||
|
return nil, errs.ErrArgs.WithDetail("text is not string")
|
||||||
|
}
|
||||||
|
bytes, err := json.Marshal(apistruct.TextContentElem{Content: text})
|
||||||
|
if err != nil {
|
||||||
|
return nil, errs.ErrArgs.WithDetail(err.Error())
|
||||||
|
}
|
||||||
|
data = apistruct.TextElem{Text: string(bytes)}
|
||||||
case constant.Picture:
|
case constant.Picture:
|
||||||
data = apistruct.PictureElem{}
|
data = apistruct.PictureElem{}
|
||||||
case constant.Voice:
|
case constant.Voice:
|
||||||
|
|||||||
@ -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