|
|
@ -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
|
|
|
|
}
|
|
|
|
}
|
|
|
|