This commit is contained in:
withchao 2023-01-09 14:28:19 +08:00
parent 6830fe5f7a
commit 10fa4318e9

View File

@ -255,29 +255,29 @@ func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbGroup.GetJo
SetErr(ctx, "GetJoinedGroupIDListFromCache", err, &resp.CommonResp.ErrCode, &resp.CommonResp.ErrMsg, "userID", req.FromUserID) SetErr(ctx, "GetJoinedGroupIDListFromCache", err, &resp.CommonResp.ErrCode, &resp.CommonResp.ErrMsg, "userID", req.FromUserID)
return return
} }
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "joinedGroupList: ", joinedGroupList) for _, groupID := range joinedGroupList {
for _, v := range joinedGroupList {
var groupNode open_im_sdk.GroupInfo var groupNode open_im_sdk.GroupInfo
num, err := rocksCache.GetGroupMemberNumFromCache(v) num, err := rocksCache.GetGroupMemberNumFromCache(groupID)
if err != nil { if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), v) log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), groupID)
continue continue
} }
owner, err2 := imdb.GetGroupOwnerInfoByGroupID(v) owner, err := (*imdb.GroupMember)(nil).TakeOwnerInfo(ctx, groupID)
if err2 != nil { //owner, err2 := imdb.GetGroupOwnerInfoByGroupID(groupID)
log.NewError(req.OperationID, utils.GetSelfFuncName(), err2.Error(), v) if err != nil {
trace_log.SetContextInfo(ctx, "TakeOwnerInfo", err, "groupID", groupID)
continue continue
} }
group, err := rocksCache.GetGroupInfoFromCache(ctx, v) group, err := rocksCache.GetGroupInfoFromCache(ctx, groupID)
if err != nil { if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), v) trace_log.SetContextInfo(ctx, "GetGroupInfoFromCache", err, "groupID", groupID)
continue continue
} }
if group.GroupType == constant.SuperGroup { if group.GroupType == constant.SuperGroup {
continue continue
} }
if group.Status == constant.GroupStatusDismissed { if group.Status == constant.GroupStatusDismissed {
log.NewError(req.OperationID, "constant.GroupStatusDismissed ", group) trace_log.SetContextInfo(ctx, "GetGroupInfoFromCache", err, "groupID", groupID)
continue continue
} }
utils.CopyStructFields(&groupNode, group) utils.CopyStructFields(&groupNode, group)
@ -290,10 +290,8 @@ func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbGroup.GetJo
groupNode.MemberCount = uint32(num) groupNode.MemberCount = uint32(num)
groupNode.OwnerUserID = owner.UserID groupNode.OwnerUserID = owner.UserID
resp.GroupList = append(resp.GroupList, &groupNode) resp.GroupList = append(resp.GroupList, &groupNode)
log.NewDebug(req.OperationID, "joinedGroup ", groupNode)
} }
log.NewInfo(req.OperationID, "GetJoinedGroupList rpc return ", resp.String()) return
return resp, nil
} }
func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.InviteUserToGroupReq) (resp *pbGroup.InviteUserToGroupResp, _ error) { func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.InviteUserToGroupReq) (resp *pbGroup.InviteUserToGroupResp, _ error) {
@ -316,8 +314,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
// TODO // TODO
//errMsg := " group status is dismissed " //errMsg := " group status is dismissed "
//return &pbGroup.InviteUserToGroupResp{ErrCode: constant.ErrStatus.ErrCode, ErrMsg: errMsg}, nil //return &pbGroup.InviteUserToGroupResp{ErrCode: constant.ErrStatus.ErrCode, ErrMsg: errMsg}, nil
resp.CommonResp.ErrCode = 1 SetErrorForResp(constant.ErrStatus, resp.CommonResp)
resp.CommonResp.ErrMsg = " group status is dismissed "
return return
} }
if groupInfo.NeedVerification == constant.AllNeedVerification && if groupInfo.NeedVerification == constant.AllNeedVerification &&
@ -1810,32 +1807,31 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr
return return
} }
func (s *groupServer) GetGroupAbstractInfo(c context.Context, req *pbGroup.GetGroupAbstractInfoReq) (*pbGroup.GetGroupAbstractInfoResp, error) { func (s *groupServer) GetGroupAbstractInfo(ctx context.Context, req *pbGroup.GetGroupAbstractInfoReq) (resp *pbGroup.GetGroupAbstractInfoResp,_ error) {
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String()) resp = &pbGroup.GetGroupAbstractInfoResp{CommonResp: &open_im_sdk.CommonResp{}}
resp := &pbGroup.GetGroupAbstractInfoResp{CommonResp: &pbGroup.CommonResp{}} ctx = trace_log.NewRpcCtx(ctx, utils.GetSelfFuncName(), req.OperationID)
defer func() {
trace_log.SetContextInfo(ctx, utils.GetSelfFuncName(), nil, "rpc req ", req.String(), "rpc resp ", resp.String())
trace_log.ShowLog(ctx)
}()
hashCode, err := rocksCache.GetGroupMemberListHashFromCache(req.GroupID) hashCode, err := rocksCache.GetGroupMemberListHashFromCache(req.GroupID)
if err != nil { if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMemberListHashFromCache failed", req.GroupID, err.Error()) SetErrorForResp(err, resp.CommonResp)
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode return
resp.CommonResp.ErrMsg = err.Error()
return resp, nil
} }
resp.GroupMemberListHash = hashCode resp.GroupMemberListHash = hashCode
num, err := rocksCache.GetGroupMemberNumFromCache(req.GroupID) num, err := rocksCache.GetGroupMemberNumFromCache(req.GroupID)
if err != nil { if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMemberNumByGroupID failed", req.GroupID, err.Error()) SetErrorForResp(err, resp.CommonResp)
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode return
resp.CommonResp.ErrMsg = err.Error()
return resp, nil
} }
resp.GroupMemberNumber = int32(num) resp.GroupMemberNumber = int32(num)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", resp.String())
return resp, nil return resp, nil
} }
func (s *groupServer) DelGroupAndUserCache(operationID, groupID string, userIDList []string) error { func (s *groupServer) DelGroupAndUserCache(operationID, groupID string, userIDList []string) error {
if groupID != "" { if groupID != "" {
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, operationID) etcdConn, err := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, operationID)
if etcdConn == nil { if etcdConn == nil {
errMsg := operationID + "getcdv3.GetDefaultConn == nil" errMsg := operationID + "getcdv3.GetDefaultConn == nil"
log.NewError(operationID, errMsg) log.NewError(operationID, errMsg)