diff --git a/internal/msg_gateway/gate/validate.go b/internal/msg_gateway/gate/validate.go index 329f93655..35bc34f0e 100644 --- a/internal/msg_gateway/gate/validate.go +++ b/internal/msg_gateway/gate/validate.go @@ -114,140 +114,3 @@ func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, er //} else } - -//func (ws *WServer) signalMessageAssemble(s *open_im_sdk.SignalReq, operationID string) (isPass bool, errCode int32, errMsg string, r *open_im_sdk.SignalResp, msgData *open_im_sdk.MsgData) { -// var msg open_im_sdk.MsgData -// var resp open_im_sdk.SignalResp -// media := open_im_media.NewMedia() -// msg.MsgFrom = constant.UserMsgType -// msg.ContentType = constant.SignalingNotification -// reqData, e := proto.Marshal(s) -// if e != nil { -// return false, 201, e.Error(), nil, nil -// } -// msg.Content = reqData -// msg.CreateTime = utils.GetCurrentTimestampByMill() -// options := make(map[string]bool, 6) -// utils.SetSwitchFromOptions(options, constant.IsHistory, false) -// utils.SetSwitchFromOptions(options, constant.IsPersistent, false) -// utils.SetSwitchFromOptions(options, constant.IsSenderSync, true) -// utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false) -// utils.SetSwitchFromOptions(options, constant.IsSenderConversationUpdate, false) -// utils.SetSwitchFromOptions(options, constant.IsUnreadCount, false) -// utils.SetSwitchFromOptions(options, constant.IsOfflinePush, true) -// msg.Options = options -// switch payload := s.Payload.(type) { -// case *open_im_sdk.SignalReq_Invite: -// token, liveURL, err2 := media.GetJoinToken(payload.Invite.Invitation.RoomID, payload.Invite.Invitation.InviterUserID, operationID, payload.Invite.Participant) -// if err2 != nil { -// return false, 202, err2.Error(), nil, nil -// } -// invite := open_im_sdk.SignalResp_Invite{&open_im_sdk.SignalInviteReply{ -// Token: token, -// RoomID: payload.Invite.Invitation.RoomID, -// LiveURL: liveURL, -// }} -// resp.Payload = &invite -// msg.SenderPlatformID = payload.Invite.Invitation.PlatformID -// msg.SessionType = payload.Invite.Invitation.SessionType -// msg.OfflinePushInfo = payload.Invite.OfflinePushInfo -// msg.SendID = payload.Invite.Invitation.InviterUserID -// if len(payload.Invite.Invitation.InviteeUserIDList) > 0 { -// msg.RecvID = payload.Invite.Invitation.InviteeUserIDList[0] -// } else { -// return false, 203, errors.New("InviteeUserIDList is null").Error(), nil, nil -// } -// msg.ClientMsgID = utils.GetMsgID(payload.Invite.Invitation.InviterUserID) -// return true, 0, "", &resp, &msg -// case *open_im_sdk.SignalReq_InviteInGroup: -// token, liveURL, err2 := media.GetJoinToken(payload.InviteInGroup.Invitation.RoomID, payload.InviteInGroup.Invitation.InviterUserID, operationID, payload.InviteInGroup.Participant) -// if err2 != nil { -// return false, 204, err2.Error(), nil, nil -// } -// inviteGroup := open_im_sdk.SignalResp_InviteInGroup{&open_im_sdk.SignalInviteInGroupReply{ -// RoomID: payload.InviteInGroup.Invitation.RoomID, -// Token: token, -// LiveURL: liveURL, -// }} -// resp.Payload = &inviteGroup -// msg.SenderPlatformID = payload.InviteInGroup.Invitation.PlatformID -// msg.SessionType = payload.InviteInGroup.Invitation.SessionType -// msg.OfflinePushInfo = payload.InviteInGroup.OfflinePushInfo -// msg.SendID = payload.InviteInGroup.Invitation.InviterUserID -// if len(payload.InviteInGroup.Invitation.InviteeUserIDList) > 0 { -// msg.GroupID = payload.InviteInGroup.Invitation.GroupID -// } else { -// return false, 205, errors.New("InviteeUserIDList is null").Error(), nil, nil -// } -// msg.ClientMsgID = utils.GetMsgID(payload.InviteInGroup.Invitation.InviterUserID) -// -// return true, 0, "", &resp, &msg -// case *open_im_sdk.SignalReq_Cancel: -// cancel := open_im_sdk.SignalResp_Cancel{&open_im_sdk.SignalCancelReply{}} -// resp.Payload = &cancel -// msg.OfflinePushInfo = payload.Cancel.OfflinePushInfo -// msg.SendID = payload.Cancel.Invitation.InviterUserID -// msg.SenderPlatformID = payload.Cancel.Invitation.PlatformID -// msg.SessionType = payload.Cancel.Invitation.SessionType -// if len(payload.Cancel.Invitation.InviteeUserIDList) > 0 { -// switch payload.Cancel.Invitation.SessionType { -// case constant.SingleChatType: -// msg.RecvID = payload.Cancel.Invitation.InviteeUserIDList[0] -// case constant.GroupChatType: -// msg.GroupID = payload.Cancel.Invitation.GroupID -// } -// } else { -// return false, 206, errors.New("InviteeUserIDList is null").Error(), nil, nil -// } -// msg.ClientMsgID = utils.GetMsgID(payload.Cancel.OpUserID) -// return true, 0, "", &resp, &msg -// case *open_im_sdk.SignalReq_Accept: -// token, liveURL, err2 := media.GetJoinToken(payload.Accept.Invitation.RoomID, payload.Accept.OpUserID, operationID, payload.Accept.Participant) -// if err2 != nil { -// return false, 207, err2.Error(), nil, nil -// } -// accept := open_im_sdk.SignalResp_Accept{&open_im_sdk.SignalAcceptReply{ -// Token: token, -// LiveURL: liveURL, -// RoomID: payload.Accept.Invitation.RoomID, -// }} -// resp.Payload = &accept -// msg.OfflinePushInfo = payload.Accept.OfflinePushInfo -// msg.SendID = payload.Accept.OpUserID -// msg.SenderPlatformID = payload.Accept.Invitation.PlatformID -// msg.SessionType = payload.Accept.Invitation.SessionType -// if len(payload.Accept.Invitation.InviteeUserIDList) > 0 { -// switch payload.Accept.Invitation.SessionType { -// case constant.SingleChatType: -// msg.RecvID = payload.Accept.Invitation.InviterUserID -// case constant.GroupChatType: -// msg.GroupID = payload.Accept.Invitation.GroupID -// } -// } else { -// return false, 208, errors.New("InviteeUserIDList is null").Error(), nil, nil -// } -// msg.ClientMsgID = utils.GetMsgID(payload.Accept.OpUserID) -// return true, 0, "", &resp, &msg -// case *open_im_sdk.SignalReq_HungUp: -// case *open_im_sdk.SignalReq_Reject: -// reject := open_im_sdk.SignalResp_Reject{&open_im_sdk.SignalRejectReply{}} -// resp.Payload = &reject -// msg.OfflinePushInfo = payload.Reject.OfflinePushInfo -// msg.SendID = payload.Reject.OpUserID -// msg.SenderPlatformID = payload.Reject.Invitation.PlatformID -// msg.SessionType = payload.Reject.Invitation.SessionType -// if len(payload.Reject.Invitation.InviteeUserIDList) > 0 { -// switch payload.Reject.Invitation.SessionType { -// case constant.SingleChatType: -// msg.RecvID = payload.Reject.Invitation.InviterUserID -// case constant.GroupChatType: -// msg.GroupID = payload.Reject.Invitation.GroupID -// } -// } else { -// return false, 209, errors.New("InviteeUserIDList is null").Error(), nil, nil -// } -// msg.ClientMsgID = utils.GetMsgID(payload.Reject.OpUserID) -// return true, 0, "", &resp, &msg -// } -// return false, 210, errors.New("InviteeUserIDList is null").Error(), nil, nil -//} diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index 7d59640d5..4266631f8 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -11,6 +11,7 @@ import ( "Open_IM/pkg/common/token_verify" cp "Open_IM/pkg/common/utils" "Open_IM/pkg/grpc-etcdv3/getcdv3" + pbCache "Open_IM/pkg/proto/cache" pbGroup "Open_IM/pkg/proto/group" open_im_sdk "Open_IM/pkg/proto/sdk_ws" pbUser "Open_IM/pkg/proto/user" @@ -136,12 +137,12 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR } okUserIDList = append(okUserIDList, user.UserID) - err = db.DB.AddGroupMember(groupId, user.UserID) - if err != nil { - log.NewError(req.OperationID, "add mongo group member failed, db.DB.AddGroupMember failed ", err.Error()) - } + // mongoDB method + //err = db.DB.AddGroupMember(groupId, user.UserID) + //if err != nil { + // log.NewError(req.OperationID, "add mongo group member failed, db.DB.AddGroupMember failed ", err.Error()) + //} } - resp := &pbGroup.CreateGroupResp{GroupInfo: &open_im_sdk.GroupInfo{}} group, err := imdb.GetGroupInfoByGroupID(groupId) if err != nil { @@ -160,8 +161,24 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR } resp.GroupInfo.OwnerUserID = req.OwnerUserID - log.NewInfo(req.OperationID, "rpc CreateGroup return ", resp.String()) + addGroupMemberToCacheReq := &pbCache.AddGroupMemberToCacheReq{ + UserIDList: okUserIDList, + GroupID: req.GroupInfo.GroupID, + OperationID: req.OperationID, + } + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) + cacheClient := pbCache.NewCacheClient(etcdConn) + cacheResp, err := cacheClient.AddGroupMemberToCache(context.Background(), addGroupMemberToCacheReq) + if err != nil { + log.NewError(req.OperationID, "AddGroupMemberToCache rpc call failed ", err.Error()) + return &pbGroup.CreateGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil + } + if cacheResp.CommonResp.ErrCode != 0 { + log.NewError(req.OperationID, "AddGroupMemberToCache rpc logic call failed ", cacheResp.String()) + return &pbGroup.CreateGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil + } + log.NewInfo(req.OperationID, "rpc CreateGroup return ", resp.String()) chat.GroupCreatedNotification(req.OperationID, req.OpUserID, groupId, okUserIDList) return resp, nil } @@ -307,6 +324,24 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "SetConversation success", respPb.String(), v) } } + + addGroupMemberToCacheReq := &pbCache.AddGroupMemberToCacheReq{ + UserIDList: okUserIDList, + GroupID: req.GroupID, + OperationID: req.OperationID, + } + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) + cacheClient := pbCache.NewCacheClient(etcdConn) + cacheResp, err := cacheClient.AddGroupMemberToCache(context.Background(), addGroupMemberToCacheReq) + if err != nil { + log.NewError(req.OperationID, "AddGroupMemberToCache rpc call failed ", err.Error()) + return &pbGroup.InviteUserToGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil + } + if cacheResp.CommonResp.ErrCode != 0 { + log.NewError(req.OperationID, "AddGroupMemberToCache rpc logic call failed ", cacheResp.String()) + return &pbGroup.InviteUserToGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil + } + chat.MemberInvitedNotification(req.OperationID, req.GroupID, req.OpUserID, req.Reason, okUserIDList) resp.ErrCode = 0 log.NewInfo(req.OperationID, "InviteUserToGroup rpc return ", resp.String()) @@ -450,6 +485,24 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "SetConversation success", respPb.String(), v) } } + + reduceGroupMemberFromCacheReq := &pbCache.ReduceGroupMemberFromCacheReq{ + UserIDList: okUserIDList, + GroupID: req.GroupID, + OperationID: req.OperationID, + } + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) + cacheClient := pbCache.NewCacheClient(etcdConn) + cacheResp, err := cacheClient.ReduceGroupMemberFromCache(context.Background(), reduceGroupMemberFromCacheReq) + if err != nil { + log.NewError(req.OperationID, "ReduceGroupMemberFromCache rpc call failed ", err.Error()) + return &pbGroup.KickGroupMemberResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil + } + if cacheResp.CommonResp.ErrCode != 0 { + log.NewError(req.OperationID, "ReduceGroupMemberFromCache rpc logic call failed ", cacheResp.String()) + return &pbGroup.KickGroupMemberResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil + } + chat.MemberKickedNotification(req, okUserIDList) log.NewInfo(req.OperationID, "GetGroupMemberList rpc return ", resp.String()) return &resp, nil @@ -691,22 +744,24 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq) } else { log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "SetConversation success", respPb.String()) } - //reduceGroupMemberFromCacheReq := &pbCache.ReduceGroupMemberFromCacheReq{ - // UserIDList: []string{req.OpUserID}, - // GroupID: req.GroupID, - // OperationID: req.OperationID, - //} - //etcdConn = getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) - //cacheClient := pbCache.NewCacheClient(etcdConn) - //respCachePb, err := cacheClient.ReduceGroupMemberFromCache(context.Background(), reduceGroupMemberFromCacheReq) - //if err != nil { - // log.NewError(req.OperationID, utils.GetSelfFuncName(), "AddFriendToCache failed", err.Error(), reduceGroupMemberFromCacheReq.String()) - // return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrServer.ErrCode, ErrMsg: constant.ErrServer.ErrMsg}}, nil - //} - //if respPb.CommonResp.ErrCode != 0 { - // log.NewError(req.OperationID, utils.GetSelfFuncName(), "AddFriendToCache failed", reduceGroupMemberFromCacheReq.String()) - // return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode:respCachePb.CommonResp.ErrCode, ErrMsg: respCachePb.CommonResp.ErrMsg}}, nil - //} + + reduceGroupMemberFromCacheReq := &pbCache.ReduceGroupMemberFromCacheReq{ + UserIDList: []string{req.OpUserID}, + GroupID: req.GroupID, + OperationID: req.OperationID, + } + etcdConnCache := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) + cacheClient := pbCache.NewCacheClient(etcdConnCache) + cacheResp, err := cacheClient.ReduceGroupMemberFromCache(context.Background(), reduceGroupMemberFromCacheReq) + if err != nil { + 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 + } + if cacheResp.CommonResp.ErrCode != 0 { + log.NewError(req.OperationID, "ReduceGroupMemberFromCache rpc logic call failed ", cacheResp.String()) + return &pbGroup.QuitGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil + } + chat.MemberQuitNotification(req) 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 @@ -1047,9 +1102,26 @@ func (s *groupServer) RemoveGroupMembersCMS(_ context.Context, req *pbGroup.Remo log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "SetConversation success", respPb.String(), v) } } + + reduceGroupMemberFromCacheReq := &pbCache.ReduceGroupMemberFromCacheReq{ + UserIDList: resp.Success, + GroupID: req.GroupId, + OperationID: req.OperationID, + } + etcdConnCache := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) + cacheClient := pbCache.NewCacheClient(etcdConnCache) + cacheResp, err := cacheClient.ReduceGroupMemberFromCache(context.Background(), reduceGroupMemberFromCacheReq) + if err != nil { + log.NewError(req.OperationID, "ReduceGroupMemberFromCache rpc call failed ", err.Error()) + return resp, http.WrapError(constant.ErrDB) + } + if cacheResp.CommonResp.ErrCode != 0 { + log.NewError(req.OperationID, "ReduceGroupMemberFromCache rpc logic call failed ", cacheResp.String()) + return resp, http.WrapError(constant.ErrDB) + } + chat.MemberKickedNotification(reqKick, resp.Success) - log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "success: ", resp.Success) - log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "failed: ", resp.Failed) + log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp) return resp, nil } @@ -1086,6 +1158,24 @@ func (s *groupServer) AddGroupMembersCMS(_ context.Context, req *pbGroup.AddGrou resp.Success = append(resp.Success, userId) } } + + addGroupMemberToCacheReq := &pbCache.AddGroupMemberToCacheReq{ + UserIDList: resp.Success, + GroupID: req.GroupId, + OperationID: req.OperationId, + } + etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName) + cacheClient := pbCache.NewCacheClient(etcdConn) + cacheResp, err := cacheClient.AddGroupMemberToCache(context.Background(), addGroupMemberToCacheReq) + if err != nil { + log.NewError(req.OperationId, "AddBlackUserToCache rpc call failed ", err.Error()) + return resp, http.WrapError(constant.ErrDB) + } + if cacheResp.CommonResp.ErrCode != 0 { + log.NewError(req.OperationId, "AddBlackUserToCache rpc logic call failed ", cacheResp.String()) + return resp, http.WrapError(constant.ErrDB) + } + chat.MemberInvitedNotification(req.OperationId, req.GroupId, req.OpUserId, "admin add you to group", resp.Success) return resp, nil } diff --git a/internal/rpc/msg/callback.go b/internal/rpc/msg/callback.go index bb8ccd700..452846799 100644 --- a/internal/rpc/msg/callback.go +++ b/internal/rpc/msg/callback.go @@ -31,6 +31,7 @@ func callbackBeforeSendSingleMsg(msg *pbChat.SendMsgReq) (canSend bool, err erro if !config.Config.Callback.CallbackBeforeSendSingleMsg.Enable { return true, nil } + log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg) commonCallbackReq := copyCallbackCommonReqStruct(msg) commonCallbackReq.CallbackCommand = constant.CallbackBeforeSendSingleMsgCommand diff --git a/internal/rpc/msg/send_msg.go b/internal/rpc/msg/send_msg.go index 013a32bd3..b8af3b145 100644 --- a/internal/rpc/msg/send_msg.go +++ b/internal/rpc/msg/send_msg.go @@ -7,9 +7,9 @@ import ( "Open_IM/pkg/common/log" "Open_IM/pkg/grpc-etcdv3/getcdv3" cacheRpc "Open_IM/pkg/proto/cache" + pbCache "Open_IM/pkg/proto/cache" pbChat "Open_IM/pkg/proto/chat" pbConversation "Open_IM/pkg/proto/conversation" - pbGroup "Open_IM/pkg/proto/group" sdk_ws "Open_IM/pkg/proto/sdk_ws" "Open_IM/pkg/utils" "context" @@ -216,28 +216,20 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendGroupMsg result", canSend, "end rpc and return") return returnMsg(&replay, pb, 201, "callbackBeforeSendGroupMsg result stop rpc and return", "", 0) } - etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName) - client := pbGroup.NewGroupClient(etcdConn) - req := &pbGroup.GetGroupAllMemberReq{ - GroupID: pb.MsgData.GroupID, - OperationID: pb.OperationID, - } - reply, err := client.GetGroupAllMember(context.Background(), req) + getGroupMemberIDListFromCacheReq := &pbCache.GetGroupMemberIDListFromCacheReq{OperationID: pb.OperationID, GroupID: pb.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.Error(pb.Token, pb.OperationID, "rpc send_msg getGroupInfo failed, err = %s", err.Error()) - return returnMsg(&replay, pb, 201, err.Error(), "", 0) + log.NewError(pb.OperationID, "GetGroupMemberIDListFromCache rpc call failed ", err.Error()) + return returnMsg(&replay, pb, 201, "GetGroupMemberIDListFromCache failed", "", 0) } - if reply.ErrCode != 0 { - log.Error(pb.Token, pb.OperationID, "rpc send_msg getGroupInfo failed, err = %s", reply.ErrMsg) - return returnMsg(&replay, pb, reply.ErrCode, reply.ErrMsg, "", 0) + if cacheResp.CommonResp.ErrCode != 0 { + log.NewError(pb.OperationID, "GetGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String()) + return returnMsg(&replay, pb, 201, "GetGroupMemberIDListFromCache logic failed", "", 0) } - memberUserIDList := func(all []*sdk_ws.GroupMemberFullInfo) (result []string) { - for _, v := range all { - result = append(result, v.UserID) - } - return result - }(reply.MemberList) - log.Debug(pb.OperationID, "GetGroupAllMember userID list", memberUserIDList) + memberUserIDList := cacheResp.UserIDList + log.Debug(pb.OperationID, "GetGroupAllMember userID list", cacheResp.UserIDList) var addUidList []string switch pb.MsgData.ContentType { case constant.MemberKickedNotification: diff --git a/pkg/common/db/redisModel.go b/pkg/common/db/redisModel.go index d39e2a57d..9996ea356 100644 --- a/pkg/common/db/redisModel.go +++ b/pkg/common/db/redisModel.go @@ -233,7 +233,7 @@ func (d *DataBases) AddGroupMemberToCache(groupID string, userIDList ...string) for _, id := range userIDList { IDList = append(IDList, id) } - _, err := d.Exec("SADD", blackListCache+groupID, IDList...) + _, err := d.Exec("SADD", groupCache+groupID, IDList...) return err } @@ -242,7 +242,7 @@ func (d *DataBases) ReduceGroupMemberFromCache(groupID string, userIDList ...str for _, id := range userIDList { IDList = append(IDList, id) } - _, err := d.Exec("SREM", blackListCache+groupID, IDList...) + _, err := d.Exec("SREM", groupCache+groupID, IDList...) return err }