Merge remote-tracking branch 'origin/superGroup' into superGroup

pull/236/head
skiffer-git 2 years ago
commit 127ad802ff

@ -1,4 +1,5 @@
# Open-IM-Server # Open-IM-Server
![avatar](https://github.com/OpenIMSDK/OpenIM-Docs/blob/main/docs/images/WechatIMG20.jpeg)
![avatar](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/open-im-logo.png) ![avatar](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/docs/open-im-logo.png)

@ -222,6 +222,7 @@ manager:
#app管理员userID和对应的secret 建议修改。 用于管理后台登录也可以用户管理后台对应的api #app管理员userID和对应的secret 建议修改。 用于管理后台登录也可以用户管理后台对应的api
appManagerUid: [ "openIM123456","openIM654321", "openIM333", "openIMAdmin"] appManagerUid: [ "openIM123456","openIM654321", "openIM333", "openIMAdmin"]
secrets: [ "openIM1","openIM2", "openIM333", "openIMAdmin"] secrets: [ "openIM1","openIM2", "openIM333", "openIMAdmin"]
appSysNotificationName: "系统通知"
secret: tuoyun secret: tuoyun
# 多端互踢策略 # 多端互踢策略
@ -233,7 +234,7 @@ chatpersistencemysql: true
#可靠性存储 #可靠性存储
reliablestorage: false reliablestorage: false
#消息缓存时间 #消息缓存时间
msgCacheTimeout: 1800 msgCacheTimeout: 86400
#群聊已读开启 #群聊已读开启
groupMessageHasReadReceiptEnable: true groupMessageHasReadReceiptEnable: true
#单聊已读开启 #单聊已读开启

@ -99,7 +99,7 @@ services:
command: /usr/local/bin/etcd --name etcd0 --data-dir /etcd-data --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379 --listen-peer-urls http://0.0.0.0:2380 --initial-advertise-peer-urls http://0.0.0.0:2380 --initial-cluster etcd0=http://0.0.0.0:2380 --initial-cluster-token tkn --initial-cluster-state new command: /usr/local/bin/etcd --name etcd0 --data-dir /etcd-data --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379 --listen-peer-urls http://0.0.0.0:2380 --initial-advertise-peer-urls http://0.0.0.0:2380 --initial-cluster etcd0=http://0.0.0.0:2380 --initial-cluster-token tkn --initial-cluster-state new
open_im_server: open_im_server:
image: openim/open_im_server:v2.0.10 image: openim/open_im_server:v2.1.0
container_name: open_im_server container_name: open_im_server
volumes: volumes:
- ./logs:/Open-IM-Server/logs - ./logs:/Open-IM-Server/logs

Binary file not shown.

Before

Width:  |  Height:  |  Size: 208 KiB

After

Width:  |  Height:  |  Size: 144 KiB

@ -174,7 +174,7 @@ func joinGroups(operationID, userID, userName string, groupIDList []string) {
GroupID: groupID, GroupID: groupID,
Reason: "register auto join", Reason: "register auto join",
InvitedUserIDList: []string{userID}, InvitedUserIDList: []string{userID},
OpUserID: config.Config.Manager.AppManagerUid[0], OpUserID: config.Config.Manager.AppManagerUid[1],
} }
resp, err := client.InviteUserToGroup(context.Background(), req) resp, err := client.InviteUserToGroup(context.Background(), req)
if err != nil { if err != nil {

@ -69,9 +69,11 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
return return
} }
} }
if err := db.DB.HandleSignalInfo(pushMsg.OperationID, pushMsg.MsgData); err != nil { if pushMsg.MsgData.ContentType == constant.SignalingNotification {
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), err.Error(), pushMsg.MsgData) if err := db.DB.HandleSignalInfo(pushMsg.OperationID, pushMsg.MsgData); err != nil {
return log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), err.Error(), pushMsg.MsgData)
return
}
} }
//Use offline push messaging //Use offline push messaging
var UIDList []string var UIDList []string
@ -153,7 +155,6 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
log.NewError(pushMsg.OperationID, errMsg) log.NewError(pushMsg.OperationID, errMsg)
return return
} }
client := pbCache.NewCacheClient(etcdConn) client := pbCache.NewCacheClient(etcdConn)
cacheResp, err := client.GetGroupMemberIDListFromCache(context.Background(), getGroupMemberIDListFromCacheReq) cacheResp, err := client.GetGroupMemberIDListFromCache(context.Background(), getGroupMemberIDListFromCacheReq)
if err != nil { if err != nil {

@ -849,45 +849,58 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq) (*pbGroup.QuitGroupResp, error) { func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq) (*pbGroup.QuitGroupResp, error) {
log.NewInfo(req.OperationID, "QuitGroup args ", req.String()) log.NewInfo(req.OperationID, "QuitGroup args ", req.String())
_, err := imdb.GetGroupMemberInfoByGroupIDAndUserID(req.GroupID, req.OpUserID) groupInfo, err := imdb.GetGroupInfoByGroupID(req.GroupID)
if err != nil { if err != nil {
log.NewError(req.OperationID, "GetGroupMemberInfoByGroupIDAndUserID failed ", err.Error(), req.GroupID, req.OpUserID) log.NewError(req.OperationID, "ReduceGroupMemberFromCache rpc call failed ", err.Error())
return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
} }
if groupInfo.GroupType != constant.SuperGroup {
_, err = imdb.GetGroupMemberInfoByGroupIDAndUserID(req.GroupID, req.OpUserID)
if err != nil {
log.NewError(req.OperationID, "GetGroupMemberInfoByGroupIDAndUserID failed ", err.Error(), req.GroupID, req.OpUserID)
return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}
err = imdb.DeleteGroupMemberByGroupIDAndUserID(req.GroupID, req.OpUserID) err = imdb.DeleteGroupMemberByGroupIDAndUserID(req.GroupID, req.OpUserID)
if err != nil { if err != nil {
log.NewError(req.OperationID, "DeleteGroupMemberByGroupIdAndUserId failed ", err.Error(), req.GroupID, req.OpUserID) log.NewError(req.OperationID, "DeleteGroupMemberByGroupIdAndUserId failed ", err.Error(), req.GroupID, req.OpUserID)
return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
} }
err = db.DB.DelGroupMember(req.GroupID, req.OpUserID) err = db.DB.DelGroupMember(req.GroupID, req.OpUserID)
if err != nil { if err != nil {
log.NewError(req.OperationID, "DelGroupMember failed ", req.GroupID, req.OpUserID) log.NewError(req.OperationID, "DelGroupMember failed ", req.GroupID, req.OpUserID)
// return &pbGroup.CommonResp{ErrorCode: constant.ErrQuitGroup.ErrCode, ErrorMsg: constant.ErrQuitGroup.ErrMsg}, nil // return &pbGroup.CommonResp{ErrorCode: constant.ErrQuitGroup.ErrCode, ErrorMsg: constant.ErrQuitGroup.ErrMsg}, nil
} }
//modify quitter conversation info //modify quitter conversation info
var reqPb pbUser.SetConversationReq var reqPb pbUser.SetConversationReq
var c pbUser.Conversation var c pbUser.Conversation
reqPb.OperationID = req.OperationID reqPb.OperationID = req.OperationID
c.OwnerUserID = req.OpUserID c.OwnerUserID = req.OpUserID
c.ConversationID = utils.GetConversationIDBySessionType(req.GroupID, constant.GroupChatType) c.ConversationID = utils.GetConversationIDBySessionType(req.GroupID, constant.GroupChatType)
c.ConversationType = constant.GroupChatType c.ConversationType = constant.GroupChatType
c.GroupID = req.GroupID c.GroupID = req.GroupID
c.IsNotInGroup = true c.IsNotInGroup = true
reqPb.Conversation = &c reqPb.Conversation = &c
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
if etcdConn == nil { if etcdConn == nil {
errMsg := req.OperationID + "getcdv3.GetConn == nil" errMsg := req.OperationID + "getcdv3.GetConn == nil"
log.NewError(req.OperationID, errMsg) log.NewError(req.OperationID, errMsg)
return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, nil return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, nil
} }
client := pbUser.NewUserClient(etcdConn) client := pbUser.NewUserClient(etcdConn)
respPb, err := client.SetConversation(context.Background(), &reqPb) respPb, err := client.SetConversation(context.Background(), &reqPb)
if err != nil { if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error()) log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
} else {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "SetConversation success", respPb.String())
}
} else { } else {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "SetConversation success", respPb.String()) okUserIDList := []string{req.OpUserID}
if err := db.DB.RemoverUserFromSuperGroup(req.GroupID, okUserIDList); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.GroupID, okUserIDList, err.Error())
return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}
} }
reduceGroupMemberFromCacheReq := &pbCache.ReduceGroupMemberFromCacheReq{ reduceGroupMemberFromCacheReq := &pbCache.ReduceGroupMemberFromCacheReq{
@ -896,7 +909,7 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq)
OperationID: req.OperationID, OperationID: req.OperationID,
} }
etcdConnCache := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID) etcdConnCache := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
if etcdConn == nil { if etcdConnCache == nil {
errMsg := req.OperationID + "getcdv3.GetConn == nil" errMsg := req.OperationID + "getcdv3.GetConn == nil"
log.NewError(req.OperationID, errMsg) log.NewError(req.OperationID, errMsg)
return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, nil return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, nil
@ -912,7 +925,12 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq)
return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
} }
chat.MemberQuitNotification(req) if groupInfo.GroupType != constant.SuperGroup {
chat.MemberQuitNotification(req)
} else {
chat.SuperGroupNotification(req.OperationID, req.OpUserID, req.GroupID)
}
log.NewInfo(req.OperationID, "rpc QuitGroup return ", pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}) log.NewInfo(req.OperationID, "rpc QuitGroup return ", pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}})
return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
} }

@ -36,7 +36,6 @@ func setOpUserInfo(opUserID, groupID string, groupMemberInfo *open_im_sdk.GroupM
return utils.Wrap(err, "") return utils.Wrap(err, "")
} }
} }
user, err := imdb.GetUserByUserID(opUserID) user, err := imdb.GetUserByUserID(opUserID)
if err != nil { if err != nil {
return utils.Wrap(err, "") return utils.Wrap(err, "")
@ -117,15 +116,16 @@ func groupNotification(contentType int32, m proto.Message, sendID, groupID, recv
} }
tips.JsonDetail, _ = marshaler.MarshalToString(m) tips.JsonDetail, _ = marshaler.MarshalToString(m)
var nickname string
from, err := imdb.GetUserByUserID(sendID) from, err := imdb.GetUserByUserID(sendID)
if err != nil { if err != nil {
log.Error(operationID, "GetUserByUserID failed ", err.Error(), sendID) log.Error(operationID, "GetUserByUserID failed ", err.Error(), sendID)
} }
nickname := ""
if from != nil { if from != nil {
nickname = from.Nickname nickname = from.Nickname
} }
to, err := imdb.GetUserByUserID(recvUserID) to, err := imdb.GetUserByUserID(recvUserID)
if err != nil { if err != nil {
log.NewWarn(operationID, "GetUserByUserID failed ", err.Error(), recvUserID) log.NewWarn(operationID, "GetUserByUserID failed ", err.Error(), recvUserID)

@ -191,8 +191,9 @@ type config struct {
} }
} }
Manager struct { Manager struct {
AppManagerUid []string `yaml:"appManagerUid"` AppManagerUid []string `yaml:"appManagerUid"`
Secrets []string `yaml:"secrets"` Secrets []string `yaml:"secrets"`
AppSysNotificationName string `yaml:"appSysNotificationName"`
} }
Kafka struct { Kafka struct {

@ -22,7 +22,11 @@ func init() {
} }
var appMgr db.User var appMgr db.User
appMgr.UserID = v appMgr.UserID = v
appMgr.Nickname = "AppManager" + utils.IntToString(k+1) if k == 0 {
appMgr.Nickname = config.Config.Manager.AppSysNotificationName
} else {
appMgr.Nickname = "AppManager" + utils.IntToString(k+1)
}
appMgr.AppMangerLevel = constant.AppAdmin appMgr.AppMangerLevel = constant.AppAdmin
err = UserRegister(appMgr) err = UserRegister(appMgr)
if err != nil { if err != nil {

Loading…
Cancel
Save