mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-06-04 06:49:21 +08:00
fix: send simple msg (#3362)
* fix: content in sendSimpleMessage * fix: send simple msg * fix: send simple msg
This commit is contained in:
parent
8b23d4f5bb
commit
4d69194f62
@ -467,6 +467,10 @@ func (m *MessageApi) SendSimpleMessage(c *gin.Context) {
|
||||
sessionType int32
|
||||
recvID string
|
||||
)
|
||||
if err = c.BindJSON(&req); err != nil {
|
||||
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
|
||||
return
|
||||
}
|
||||
err = json.Unmarshal(decodedData, &keyMsgData)
|
||||
if err != nil {
|
||||
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
|
||||
@ -490,6 +494,11 @@ func (m *MessageApi) SendSimpleMessage(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
content, err := jsonutil.JsonMarshal(apistruct.MarkdownTextElem{Content: req.Content})
|
||||
if err != nil {
|
||||
apiresp.GinError(c, errs.Wrap(err))
|
||||
return
|
||||
}
|
||||
msgData := &sdkws.MsgData{
|
||||
SendID: sendID,
|
||||
RecvID: recvID,
|
||||
@ -498,17 +507,17 @@ func (m *MessageApi) SendSimpleMessage(c *gin.Context) {
|
||||
SenderPlatformID: constant.AdminPlatformID,
|
||||
SessionType: sessionType,
|
||||
MsgFrom: constant.UserMsgType,
|
||||
ContentType: constant.Text,
|
||||
Content: []byte(req.Content),
|
||||
ContentType: constant.MarkdownText,
|
||||
Content: content,
|
||||
OfflinePushInfo: req.OfflinePushInfo,
|
||||
Ex: req.Ex,
|
||||
}
|
||||
|
||||
sendReq := &msg.SendMsgReq{
|
||||
sendReq := &msg.SendSimpleMsgReq{
|
||||
MsgData: msgData,
|
||||
}
|
||||
|
||||
respPb, err := m.Client.SendMsg(c, sendReq)
|
||||
respPb, err := m.Client.SendSimpleMsg(c, sendReq)
|
||||
if err != nil {
|
||||
apiresp.GinError(c, err)
|
||||
return
|
||||
@ -525,7 +534,12 @@ func (m *MessageApi) SendSimpleMessage(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
m.ginRespSendMsg(c, sendReq, respPb)
|
||||
m.ginRespSendMsg(c, &msg.SendMsgReq{MsgData: sendReq.MsgData}, &msg.SendMsgResp{
|
||||
ServerMsgID: respPb.ServerMsgID,
|
||||
ClientMsgID: respPb.ClientMsgID,
|
||||
SendTime: respPb.SendTime,
|
||||
Modify: respPb.Modify,
|
||||
})
|
||||
}
|
||||
|
||||
func (m *MessageApi) CheckMsgIsSendSuccess(c *gin.Context) {
|
||||
|
@ -250,6 +250,7 @@ func newGinRouter(ctx context.Context, client discovery.Conn, cfg *Config) (*gin
|
||||
msgGroup.POST("/delete_msg_physical", m.DeleteMsgPhysical)
|
||||
|
||||
msgGroup.POST("/batch_send_msg", m.BatchSendMsg)
|
||||
msgGroup.POST("/send_simple_msg", m.SendSimpleMessage)
|
||||
msgGroup.POST("/check_msg_is_send_success", m.CheckMsgIsSendSuccess)
|
||||
msgGroup.POST("/get_server_time", m.GetServerTime)
|
||||
}
|
||||
|
@ -201,3 +201,25 @@ func (m *msgServer) sendMsgSingleChat(ctx context.Context, req *pbmsg.SendMsgReq
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (m *msgServer) SendSimpleMsg(ctx context.Context, req *pbmsg.SendSimpleMsgReq) (*pbmsg.SendSimpleMsgResp, error) {
|
||||
if req.MsgData == nil {
|
||||
return nil, errs.ErrArgs.WrapMsg("msg data is nil")
|
||||
}
|
||||
sender, err := m.UserLocalCache.GetUserInfo(ctx, req.MsgData.SendID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.MsgData.SenderFaceURL = sender.FaceURL
|
||||
req.MsgData.SenderNickname = sender.Nickname
|
||||
resp, err := m.SendMsg(ctx, &pbmsg.SendMsgReq{MsgData: req.MsgData})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &pbmsg.SendSimpleMsgResp{
|
||||
ServerMsgID: resp.ServerMsgID,
|
||||
ClientMsgID: resp.ClientMsgID,
|
||||
SendTime: resp.SendTime,
|
||||
Modify: resp.Modify,
|
||||
}, nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user