|
|
@ -2,12 +2,15 @@ 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"
|
|
|
|
promePkg "github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
|
|
|
|
promePkg "github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
|
|
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
|
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
|
|
|
|
|
|
|
pbConversation "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
|
|
|
|
pbMsg "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
|
|
|
|
pbMsg "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
|
|
|
|
|
|
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
|
|
|
|
|
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/wrapperspb"
|
|
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
|
|
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -46,6 +49,9 @@ func (m *msgServer) sendMsgSuperGroupChat(ctx context.Context, req *pbMsg.SendMs
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if req.MsgData.ContentType == constant.AtText {
|
|
|
|
|
|
|
|
go m.setConversationAtInfo(ctx, req.MsgData)
|
|
|
|
|
|
|
|
}
|
|
|
|
if err = callbackAfterSendGroupMsg(ctx, req); err != nil {
|
|
|
|
if err = callbackAfterSendGroupMsg(ctx, req); err != nil {
|
|
|
|
log.ZWarn(ctx, "CallbackAfterSendGroupMsg", err)
|
|
|
|
log.ZWarn(ctx, "CallbackAfterSendGroupMsg", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -56,6 +62,47 @@ func (m *msgServer) sendMsgSuperGroupChat(ctx context.Context, req *pbMsg.SendMs
|
|
|
|
resp.ClientMsgID = req.MsgData.ClientMsgID
|
|
|
|
resp.ClientMsgID = req.MsgData.ClientMsgID
|
|
|
|
return resp, nil
|
|
|
|
return resp, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *msgServer) setConversationAtInfo(nctx context.Context, msg *sdkws.MsgData) {
|
|
|
|
|
|
|
|
log.ZDebug(nctx, "setConversationAtInfo", "msg", msg)
|
|
|
|
|
|
|
|
ctx := mcontext.NewCtx("@@@" + mcontext.GetOperationID(nctx))
|
|
|
|
|
|
|
|
var atUserID []string
|
|
|
|
|
|
|
|
conversation := &pbConversation.ConversationReq{
|
|
|
|
|
|
|
|
ConversationID: utils.GetConversationIDByMsg(msg),
|
|
|
|
|
|
|
|
ConversationType: msg.SessionType,
|
|
|
|
|
|
|
|
GroupID: msg.GroupID,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
tagAll := utils.IsContain(constant.AtAllString, msg.AtUserIDList)
|
|
|
|
|
|
|
|
if tagAll {
|
|
|
|
|
|
|
|
memberUserIDList, err := m.Group.GetGroupMemberIDs(ctx, msg.GroupID)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
log.ZWarn(ctx, "GetGroupMemberIDs", err)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
atUserID = utils.DifferenceString([]string{constant.AtAllString}, msg.AtUserIDList)
|
|
|
|
|
|
|
|
if len(atUserID) == 0 { //just @everyone
|
|
|
|
|
|
|
|
conversation.GroupAtType = &wrapperspb.Int32Value{Value: constant.AtAll}
|
|
|
|
|
|
|
|
} else { //@Everyone and @other people
|
|
|
|
|
|
|
|
conversation.GroupAtType = &wrapperspb.Int32Value{Value: constant.AtAllAtMe}
|
|
|
|
|
|
|
|
err := m.Conversation.SetConversations(ctx, atUserID, conversation)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
log.ZWarn(ctx, "SetConversations", err, "userID", atUserID, "conversation", conversation)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
memberUserIDList = utils.DifferenceString(atUserID, memberUserIDList)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
conversation.GroupAtType = &wrapperspb.Int32Value{Value: constant.AtAll}
|
|
|
|
|
|
|
|
err = m.Conversation.SetConversations(ctx, memberUserIDList, conversation)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
log.ZWarn(ctx, "SetConversations", err, "userID", memberUserIDList, "conversation", conversation)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
conversation.GroupAtType = &wrapperspb.Int32Value{Value: constant.AtMe}
|
|
|
|
|
|
|
|
err := m.Conversation.SetConversations(ctx, msg.AtUserIDList, conversation)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
log.ZWarn(ctx, "SetConversations", err, msg.AtUserIDList, conversation)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (m *msgServer) sendMsgNotification(ctx context.Context, req *pbMsg.SendMsgReq) (resp *pbMsg.SendMsgResp, err error) {
|
|
|
|
func (m *msgServer) sendMsgNotification(ctx context.Context, req *pbMsg.SendMsgReq) (resp *pbMsg.SendMsgResp, err error) {
|
|
|
|
promePkg.Inc(promePkg.SingleChatMsgRecvSuccessCounter)
|
|
|
|
promePkg.Inc(promePkg.SingleChatMsgRecvSuccessCounter)
|
|
|
|