mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-25 02:58:26 +08:00
Merge branch 'superGroup' of github.com:OpenIMSDK/Open-IM-Server into superGroup
This commit is contained in:
commit
4f1bd4e509
@ -12,6 +12,7 @@ import (
|
|||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
|
pbCache "Open_IM/pkg/proto/cache"
|
||||||
pbPush "Open_IM/pkg/proto/push"
|
pbPush "Open_IM/pkg/proto/push"
|
||||||
pbRelay "Open_IM/pkg/proto/relay"
|
pbRelay "Open_IM/pkg/proto/relay"
|
||||||
pbRtc "Open_IM/pkg/proto/rtc"
|
pbRtc "Open_IM/pkg/proto/rtc"
|
||||||
@ -138,102 +139,116 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
|
func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
|
||||||
|
var wsResult []*pbRelay.SingelMsgToUserResultList
|
||||||
|
isOfflinePush := utils.GetSwitchFromOptions(pushMsg.MsgData.Options, constant.IsOfflinePush)
|
||||||
|
log.Debug(pushMsg.OperationID, "Get super group msg from msg_transfer And push msg", pushMsg.String())
|
||||||
|
getGroupMemberIDListFromCacheReq := &pbCache.GetGroupMemberIDListFromCacheReq{OperationID: pushMsg.OperationID, GroupID: pushMsg.MsgData.GroupID}
|
||||||
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName)
|
||||||
|
client := pbCache.NewCacheClient(etcdConn)
|
||||||
|
cacheResp, err := client.GetGroupMemberIDListFromCache(context.Background(), getGroupMemberIDListFromCacheReq)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(pushMsg.OperationID, "GetGroupMemberIDListFromCache rpc call failed ", err.Error())
|
||||||
return
|
return
|
||||||
//var wsResult []*pbRelay.SingelMsgToUserResultList
|
}
|
||||||
//isOfflinePush := utils.GetSwitchFromOptions(pushMsg.MsgData.Options, constant.IsOfflinePush)
|
if cacheResp.CommonResp.ErrCode != 0 {
|
||||||
//log.Debug(pushMsg.OperationID, "Get msg from msg_transfer And push msg", pushMsg.String())
|
log.NewError(pushMsg.OperationID, "GetGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
|
||||||
//if len(grpcCons) == 0 {
|
return
|
||||||
// log.NewWarn(pushMsg.OperationID, "first GetConn4Unique ")
|
}
|
||||||
// grpcCons = getcdv3.GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOnlineMessageRelayName)
|
if len(grpcCons) == 0 {
|
||||||
//}
|
log.NewWarn(pushMsg.OperationID, "first GetConn4Unique ")
|
||||||
////Online push message
|
grpcCons = getcdv3.GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOnlineMessageRelayName)
|
||||||
//log.Debug("test", pushMsg.OperationID, "len grpc", len(grpcCons), "data", pushMsg.String())
|
}
|
||||||
//for _, v := range grpcCons {
|
//Online push message
|
||||||
// msgClient := pbRelay.NewOnlineMessageRelayServiceClient(v)
|
log.Debug("test", pushMsg.OperationID, "len grpc", len(grpcCons), "data", pushMsg.String())
|
||||||
// reply, err := msgClient.OnlineBatchPushOneMsg(context.Background(), &pbRelay.OnlineBatchPushOneMsgReq{OperationID: pushMsg.OperationID, MsgData: pushMsg.MsgData, PushToUserIDList: pushMsg.PushToUserID})
|
for _, v := range grpcCons {
|
||||||
// if err != nil {
|
msgClient := pbRelay.NewOnlineMessageRelayServiceClient(v)
|
||||||
// log.NewError("push data to client rpc err", pushMsg.OperationID, "err", err)
|
reply, err := msgClient.OnlineBatchPushOneMsg(context.Background(), &pbRelay.OnlineBatchPushOneMsgReq{OperationID: pushMsg.OperationID, MsgData: pushMsg.MsgData, PushToUserIDList: cacheResp.UserIDList})
|
||||||
// continue
|
if err != nil {
|
||||||
// }
|
log.NewError("push data to client rpc err", pushMsg.OperationID, "err", err)
|
||||||
// if reply != nil && reply.SinglePushResult != nil {
|
continue
|
||||||
// wsResult = append(wsResult, reply.SinglePushResult...)
|
}
|
||||||
// }
|
if reply != nil && reply.SinglePushResult != nil {
|
||||||
//}
|
wsResult = append(wsResult, reply.SinglePushResult...)
|
||||||
//log.Debug(pushMsg.OperationID, "push_result", wsResult, "sendData", pushMsg.MsgData)
|
}
|
||||||
//successCount++
|
}
|
||||||
//if isOfflinePush && pushMsg.PushToUserID != pushMsg.MsgData.SendID {
|
log.Debug(pushMsg.OperationID, "push_result", wsResult, "sendData", pushMsg.MsgData)
|
||||||
// for _, v := range wsResult {
|
successCount++
|
||||||
// if v.ResultCode == 0 {
|
if isOfflinePush {
|
||||||
// if utils.IsContainInt32(v.RecvPlatFormID, pushTerminal) {
|
var onlineSuccessUserIDList []string
|
||||||
// break
|
onlineSuccessUserIDList = append(onlineSuccessUserIDList, pushMsg.MsgData.SendID)
|
||||||
// }
|
for _, v := range wsResult {
|
||||||
// continue
|
if v.OnlinePush && v.UserID != pushMsg.MsgData.SendID {
|
||||||
// }
|
onlineSuccessUserIDList = append(onlineSuccessUserIDList, v.UserID)
|
||||||
// if utils.IsContainInt32(v.RecvPlatFormID, pushTerminal) {
|
}
|
||||||
// //Use offline push messaging
|
}
|
||||||
// var UIDList []string
|
onlineFailedUserIDList := utils.DifferenceString(onlineSuccessUserIDList, cacheResp.UserIDList)
|
||||||
// UIDList = append(UIDList, v.RecvID)
|
//Use offline push messaging
|
||||||
// customContent := OpenIMContent{
|
customContent := OpenIMContent{
|
||||||
// SessionType: int(pushMsg.MsgData.SessionType),
|
SessionType: int(pushMsg.MsgData.SessionType),
|
||||||
// From: pushMsg.MsgData.SendID,
|
From: pushMsg.MsgData.SendID,
|
||||||
// To: pushMsg.MsgData.RecvID,
|
To: pushMsg.MsgData.RecvID,
|
||||||
// Seq: pushMsg.MsgData.Seq,
|
Seq: pushMsg.MsgData.Seq,
|
||||||
// }
|
}
|
||||||
// bCustomContent, _ := json.Marshal(customContent)
|
bCustomContent, _ := json.Marshal(customContent)
|
||||||
// jsonCustomContent := string(bCustomContent)
|
jsonCustomContent := string(bCustomContent)
|
||||||
// var content string
|
var content string
|
||||||
// if pushMsg.MsgData.OfflinePushInfo != nil {
|
if pushMsg.MsgData.OfflinePushInfo != nil {
|
||||||
// content = pushMsg.MsgData.OfflinePushInfo.Title
|
content = pushMsg.MsgData.OfflinePushInfo.Title
|
||||||
//
|
|
||||||
// } else {
|
} else {
|
||||||
// switch pushMsg.MsgData.ContentType {
|
switch pushMsg.MsgData.ContentType {
|
||||||
// case constant.Text:
|
case constant.Text:
|
||||||
// content = constant.ContentType2PushContent[constant.Text]
|
content = constant.ContentType2PushContent[constant.Text]
|
||||||
// case constant.Picture:
|
case constant.Picture:
|
||||||
// content = constant.ContentType2PushContent[constant.Picture]
|
content = constant.ContentType2PushContent[constant.Picture]
|
||||||
// case constant.Voice:
|
case constant.Voice:
|
||||||
// content = constant.ContentType2PushContent[constant.Voice]
|
content = constant.ContentType2PushContent[constant.Voice]
|
||||||
// case constant.Video:
|
case constant.Video:
|
||||||
// content = constant.ContentType2PushContent[constant.Video]
|
content = constant.ContentType2PushContent[constant.Video]
|
||||||
// case constant.File:
|
case constant.File:
|
||||||
// content = constant.ContentType2PushContent[constant.File]
|
content = constant.ContentType2PushContent[constant.File]
|
||||||
// case constant.AtText:
|
case constant.AtText:
|
||||||
// a := AtContent{}
|
a := AtContent{}
|
||||||
// _ = utils.JsonStringToStruct(string(pushMsg.MsgData.Content), &a)
|
_ = utils.JsonStringToStruct(string(pushMsg.MsgData.Content), &a)
|
||||||
// if utils.IsContain(v.RecvID, a.AtUserList) {
|
if utils.IsContain(pushMsg.PushToUserID, a.AtUserList) {
|
||||||
// content = constant.ContentType2PushContent[constant.AtText] + constant.ContentType2PushContent[constant.Common]
|
content = constant.ContentType2PushContent[constant.AtText] + constant.ContentType2PushContent[constant.Common]
|
||||||
// } else {
|
} else {
|
||||||
// content = constant.ContentType2PushContent[constant.GroupMsg]
|
content = constant.ContentType2PushContent[constant.GroupMsg]
|
||||||
// }
|
}
|
||||||
// default:
|
case constant.SignalingNotification:
|
||||||
// content = constant.ContentType2PushContent[constant.Common]
|
content = constant.ContentType2PushContent[constant.SignalMsg]
|
||||||
// }
|
default:
|
||||||
// }
|
content = constant.ContentType2PushContent[constant.Common]
|
||||||
// callbackResp := callbackOfflinePush(pushMsg.OperationID, UIDList[0], pushMsg.MsgData.OfflinePushInfo, v.RecvPlatFormID)
|
|
||||||
// log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offline callback Resp")
|
}
|
||||||
// if callbackResp.ErrCode != 0 {
|
}
|
||||||
// log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "callbackOfflinePush result: ", callbackResp)
|
|
||||||
// }
|
callbackResp := callbackOfflinePush(pushMsg.OperationID, onlineFailedUserIDList[0], pushMsg.MsgData)
|
||||||
// if callbackResp.ActionCode != constant.ActionAllow {
|
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offline callback Resp")
|
||||||
// log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offlinePush stop")
|
if callbackResp.ErrCode != 0 {
|
||||||
// break
|
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "callbackOfflinePush result: ", callbackResp)
|
||||||
// }
|
}
|
||||||
//
|
if callbackResp.ActionCode != constant.ActionAllow {
|
||||||
// if offlinePusher == nil {
|
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offlinePush stop")
|
||||||
// offlinePusher = jpush.JPushClient
|
return
|
||||||
// }
|
}
|
||||||
// pushResult, err := offlinePusher.Push(UIDList, content, jsonCustomContent, pushMsg.OperationID)
|
if offlinePusher == nil {
|
||||||
// if err != nil {
|
return
|
||||||
// log.NewError(pushMsg.OperationID, "offline push error", pushMsg.String(), err.Error())
|
}
|
||||||
// } else {
|
opts, err := GetOfflinePushOpts(pushMsg)
|
||||||
// log.NewDebug(pushMsg.OperationID, "offline push return result is ", pushResult, pushMsg.MsgData)
|
if err != nil {
|
||||||
// }
|
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "GetOfflinePushOpts failed", pushMsg, err.Error())
|
||||||
// break
|
}
|
||||||
// }
|
log.NewInfo(pushMsg.OperationID, utils.GetSelfFuncName(), onlineFailedUserIDList, content, jsonCustomContent, "opts:", opts)
|
||||||
//
|
pushResult, err := offlinePusher.Push(onlineFailedUserIDList, content, jsonCustomContent, pushMsg.OperationID, opts)
|
||||||
// }
|
if err != nil {
|
||||||
//
|
log.NewError(pushMsg.OperationID, "offline push error", pushMsg.String(), err.Error())
|
||||||
//}
|
} else {
|
||||||
|
log.NewDebug(pushMsg.OperationID, "offline push return result is ", pushResult, pushMsg.MsgData)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetOfflinePushOpts(pushMsg *pbPush.PushMsgReq) (opts push.PushOpts, err error) {
|
func GetOfflinePushOpts(pushMsg *pbPush.PushMsgReq) (opts push.PushOpts, err error) {
|
||||||
|
@ -1448,11 +1448,11 @@ func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGrou
|
|||||||
return &pbGroup.MuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
return &pbGroup.MuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
||||||
}
|
}
|
||||||
if mutedInfo.RoleLevel == constant.GroupOwner && opFlag != 1 {
|
if mutedInfo.RoleLevel == constant.GroupOwner && opFlag != 1 {
|
||||||
errMsg := req.OperationID + " mutedInfo.RoleLevel == constant.GroupOwner " + req.GroupID + req.UserID + err.Error()
|
errMsg := req.OperationID + " mutedInfo.RoleLevel == constant.GroupOwner " + req.GroupID + req.UserID
|
||||||
return &pbGroup.MuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
return &pbGroup.MuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
||||||
}
|
}
|
||||||
if mutedInfo.RoleLevel == constant.GroupAdmin && opFlag == 3 {
|
if mutedInfo.RoleLevel == constant.GroupAdmin && opFlag == 3 {
|
||||||
errMsg := req.OperationID + " mutedInfo.RoleLevel == constant.GroupAdmin " + req.GroupID + req.UserID + err.Error()
|
errMsg := req.OperationID + " mutedInfo.RoleLevel == constant.GroupAdmin " + req.GroupID + req.UserID
|
||||||
return &pbGroup.MuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
return &pbGroup.MuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1490,11 +1490,11 @@ func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.Ca
|
|||||||
return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
||||||
}
|
}
|
||||||
if mutedInfo.RoleLevel == constant.GroupOwner && opFlag != 1 {
|
if mutedInfo.RoleLevel == constant.GroupOwner && opFlag != 1 {
|
||||||
errMsg := req.OperationID + " mutedInfo.RoleLevel == constant.GroupOwner " + req.GroupID + req.UserID + err.Error()
|
errMsg := req.OperationID + " mutedInfo.RoleLevel == constant.GroupOwner " + req.GroupID + req.UserID
|
||||||
return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
||||||
}
|
}
|
||||||
if mutedInfo.RoleLevel == constant.GroupAdmin && opFlag == 3 {
|
if mutedInfo.RoleLevel == constant.GroupAdmin && opFlag == 3 {
|
||||||
errMsg := req.OperationID + " mutedInfo.RoleLevel == constant.GroupAdmin " + req.GroupID + req.UserID + err.Error()
|
errMsg := req.OperationID + " mutedInfo.RoleLevel == constant.GroupAdmin " + req.GroupID + req.UserID
|
||||||
return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1577,7 +1577,7 @@ func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMu
|
|||||||
// errMsg := req.OperationID + " mutedInfo.RoleLevel == constant.GroupAdmin " + req.GroupID + req.OpUserID + err.Error()
|
// errMsg := req.OperationID + " mutedInfo.RoleLevel == constant.GroupAdmin " + req.GroupID + req.OpUserID + err.Error()
|
||||||
// return &pbGroup.CancelMuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
// return &pbGroup.CancelMuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
||||||
//}
|
//}
|
||||||
|
log.Debug(req.OperationID, "UpdateGroupInfoDefaultZero ", req.GroupID, map[string]interface{}{"status": constant.GroupOk})
|
||||||
err = imdb.UpdateGroupInfoDefaultZero(req.GroupID, map[string]interface{}{"status": constant.GroupOk})
|
err = imdb.UpdateGroupInfoDefaultZero(req.GroupID, map[string]interface{}{"status": constant.GroupOk})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(req.OperationID, "UpdateGroupInfoDefaultZero failed ", err.Error(), req.GroupID)
|
log.Error(req.OperationID, "UpdateGroupInfoDefaultZero failed ", err.Error(), req.GroupID)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user