msg destruct

test-v3dev1
wangchuxiao 1 year ago
parent c02f3cc8d5
commit 7059d6b5fb

@ -2,6 +2,7 @@ package msg
import ( import (
"context" "context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
@ -16,20 +17,24 @@ import (
func (m *msgServer) SendMsg(ctx context.Context, req *pbMsg.SendMsgReq) (resp *pbMsg.SendMsgResp, error error) { func (m *msgServer) SendMsg(ctx context.Context, req *pbMsg.SendMsgReq) (resp *pbMsg.SendMsgResp, error error) {
resp = &pbMsg.SendMsgResp{} resp = &pbMsg.SendMsgResp{}
flag := isMessageHasReadEnabled(req.MsgData) if req.MsgData != nil {
if !flag { flag := isMessageHasReadEnabled(req.MsgData)
return nil, errs.ErrMessageHasReadDisable.Wrap() if !flag {
} return nil, errs.ErrMessageHasReadDisable.Wrap()
m.encapsulateMsgData(req.MsgData) }
switch req.MsgData.SessionType { m.encapsulateMsgData(req.MsgData)
case constant.SingleChatType: switch req.MsgData.SessionType {
return m.sendMsgSingleChat(ctx, req) case constant.SingleChatType:
case constant.NotificationChatType: return m.sendMsgSingleChat(ctx, req)
return m.sendMsgNotification(ctx, req) case constant.NotificationChatType:
case constant.SuperGroupChatType: return m.sendMsgNotification(ctx, req)
return m.sendMsgSuperGroupChat(ctx, req) case constant.SuperGroupChatType:
default: return m.sendMsgSuperGroupChat(ctx, req)
return nil, errs.ErrArgs.Wrap("unknown sessionType") default:
return nil, errs.ErrArgs.Wrap("unknown sessionType")
}
} else {
return nil, errs.ErrArgs.Wrap("msgData is nil")
} }
} }

Loading…
Cancel
Save