mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-08-11 05:46:27 +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
|
sessionType int32
|
||||||
recvID string
|
recvID string
|
||||||
)
|
)
|
||||||
|
if err = c.BindJSON(&req); err != nil {
|
||||||
|
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
|
||||||
|
return
|
||||||
|
}
|
||||||
err = json.Unmarshal(decodedData, &keyMsgData)
|
err = json.Unmarshal(decodedData, &keyMsgData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
|
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
|
||||||
@ -490,6 +494,11 @@ func (m *MessageApi) SendSimpleMessage(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
content, err := jsonutil.JsonMarshal(apistruct.MarkdownTextElem{Content: req.Content})
|
||||||
|
if err != nil {
|
||||||
|
apiresp.GinError(c, errs.Wrap(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
msgData := &sdkws.MsgData{
|
msgData := &sdkws.MsgData{
|
||||||
SendID: sendID,
|
SendID: sendID,
|
||||||
RecvID: recvID,
|
RecvID: recvID,
|
||||||
@ -498,17 +507,17 @@ func (m *MessageApi) SendSimpleMessage(c *gin.Context) {
|
|||||||
SenderPlatformID: constant.AdminPlatformID,
|
SenderPlatformID: constant.AdminPlatformID,
|
||||||
SessionType: sessionType,
|
SessionType: sessionType,
|
||||||
MsgFrom: constant.UserMsgType,
|
MsgFrom: constant.UserMsgType,
|
||||||
ContentType: constant.Text,
|
ContentType: constant.MarkdownText,
|
||||||
Content: []byte(req.Content),
|
Content: content,
|
||||||
OfflinePushInfo: req.OfflinePushInfo,
|
OfflinePushInfo: req.OfflinePushInfo,
|
||||||
Ex: req.Ex,
|
Ex: req.Ex,
|
||||||
}
|
}
|
||||||
|
|
||||||
sendReq := &msg.SendMsgReq{
|
sendReq := &msg.SendSimpleMsgReq{
|
||||||
MsgData: msgData,
|
MsgData: msgData,
|
||||||
}
|
}
|
||||||
|
|
||||||
respPb, err := m.Client.SendMsg(c, sendReq)
|
respPb, err := m.Client.SendSimpleMsg(c, sendReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
apiresp.GinError(c, err)
|
apiresp.GinError(c, err)
|
||||||
return
|
return
|
||||||
@ -525,7 +534,12 @@ func (m *MessageApi) SendSimpleMessage(c *gin.Context) {
|
|||||||
return
|
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) {
|
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("/delete_msg_physical", m.DeleteMsgPhysical)
|
||||||
|
|
||||||
msgGroup.POST("/batch_send_msg", m.BatchSendMsg)
|
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("/check_msg_is_send_success", m.CheckMsgIsSendSuccess)
|
||||||
msgGroup.POST("/get_server_time", m.GetServerTime)
|
msgGroup.POST("/get_server_time", m.GetServerTime)
|
||||||
}
|
}
|
||||||
|
@ -201,3 +201,25 @@ func (m *msgServer) sendMsgSingleChat(ctx context.Context, req *pbmsg.SendMsgReq
|
|||||||
}, nil
|
}, 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