|
|
@ -254,29 +254,28 @@ func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbGroup.GetJo
|
|
|
|
constant.SetErrorForResp(err, resp.CommonResp)
|
|
|
|
constant.SetErrorForResp(err, resp.CommonResp)
|
|
|
|
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(ctx, 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)
|
|
|
|
|
|
|
|
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)
|
|
|
@ -289,10 +288,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) {
|
|
|
@ -864,6 +861,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
|
|
|
|
constant.SetErrorForResp(err, resp.CommonResp)
|
|
|
|
constant.SetErrorForResp(err, resp.CommonResp)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var sessionType int
|
|
|
|
var sessionType int
|
|
|
|
if groupInfo.GroupType == constant.NormalGroup {
|
|
|
|
if groupInfo.GroupType == constant.NormalGroup {
|
|
|
|
sessionType = constant.GroupChatType
|
|
|
|
sessionType = constant.GroupChatType
|
|
|
@ -1390,65 +1388,71 @@ func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGrou
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.CancelMuteGroupMemberReq) (*pbGroup.CancelMuteGroupMemberResp, error) {
|
|
|
|
func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.CancelMuteGroupMemberReq) (resp *pbGroup.CancelMuteGroupMemberResp, _ error) {
|
|
|
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc args ", req.String())
|
|
|
|
resp = &pbGroup.CancelMuteGroupMemberResp{CommonResp: &open_im_sdk.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)
|
|
|
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
opFlag, err := s.getGroupUserLevel(req.GroupID, req.OpUserID)
|
|
|
|
opFlag, err := s.getGroupUserLevel(req.GroupID, req.OpUserID)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
errMsg := req.OperationID + " getGroupUserLevel failed " + req.GroupID + req.OpUserID + err.Error()
|
|
|
|
SetErrorForResp(err, resp.CommonResp)
|
|
|
|
log.Error(req.OperationID, errMsg)
|
|
|
|
return
|
|
|
|
return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if opFlag == 0 {
|
|
|
|
if opFlag == 0 {
|
|
|
|
errMsg := req.OperationID + "opFlag == 0 " + req.GroupID + req.OpUserID
|
|
|
|
SetErrorForResp(constant.ErrAccess, resp.CommonResp)
|
|
|
|
log.Error(req.OperationID, errMsg)
|
|
|
|
return
|
|
|
|
return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mutedInfo, err := imdb.GetGroupMemberInfoByGroupIDAndUserID(req.GroupID, req.UserID)
|
|
|
|
mutedInfo, err := imdb.GetGroupMemberInfoByGroupIDAndUserID(req.GroupID, req.UserID)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
errMsg := req.OperationID + " GetGroupMemberInfoByGroupIDAndUserID failed " + req.GroupID + req.UserID + err.Error()
|
|
|
|
SetErrorForResp(err, resp.CommonResp)
|
|
|
|
return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
|
|
|
SetErrorForResp(err, resp.CommonResp)
|
|
|
|
return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
|
|
|
SetErrorForResp(err, resp.CommonResp)
|
|
|
|
return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.UserID); err != nil {
|
|
|
|
if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.UserID); err != nil {
|
|
|
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
|
|
|
SetErrorForResp(err, resp.CommonResp)
|
|
|
|
return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}}, nil
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
groupMemberInfo := imdb.GroupMember{GroupID: req.GroupID, UserID: req.UserID}
|
|
|
|
groupMemberInfo := imdb.GroupMember{GroupID: req.GroupID, UserID: req.UserID}
|
|
|
|
groupMemberInfo.MuteEndTime = time.Unix(0, 0)
|
|
|
|
groupMemberInfo.MuteEndTime = time.Unix(0, 0)
|
|
|
|
err = imdb.UpdateGroupMemberInfo(groupMemberInfo)
|
|
|
|
err = imdb.UpdateGroupMemberInfo(groupMemberInfo)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Error(req.OperationID, "UpdateGroupMemberInfo failed ", err.Error(), groupMemberInfo)
|
|
|
|
SetErrorForResp(err, resp.CommonResp)
|
|
|
|
return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
chat.GroupMemberCancelMutedNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID)
|
|
|
|
chat.GroupMemberCancelMutedNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID)
|
|
|
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""})
|
|
|
|
return
|
|
|
|
return &pbGroup.CancelMuteGroupMemberResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s *groupServer) MuteGroup(ctx context.Context, req *pbGroup.MuteGroupReq) (*pbGroup.MuteGroupResp, error) {
|
|
|
|
func (s *groupServer) MuteGroup(ctx context.Context, req *pbGroup.MuteGroupReq) (resp *pbGroup.MuteGroupResp, _ error) {
|
|
|
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc args ", req.String())
|
|
|
|
resp = &pbGroup.MuteGroupResp{CommonResp: &open_im_sdk.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)
|
|
|
|
|
|
|
|
}()
|
|
|
|
opFlag, err := s.getGroupUserLevel(req.GroupID, req.OpUserID)
|
|
|
|
opFlag, err := s.getGroupUserLevel(req.GroupID, req.OpUserID)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
errMsg := req.OperationID + " getGroupUserLevel failed " + req.GroupID + req.OpUserID + err.Error()
|
|
|
|
SetErrorForResp(err, resp.CommonResp)
|
|
|
|
log.Error(req.OperationID, errMsg)
|
|
|
|
return
|
|
|
|
return &pbGroup.MuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if opFlag == 0 {
|
|
|
|
if opFlag == 0 {
|
|
|
|
errMsg := req.OperationID + "opFlag == 0 " + req.GroupID + req.OpUserID
|
|
|
|
//errMsg := req.OperationID + "opFlag == 0 " + req.GroupID + req.OpUserID
|
|
|
|
log.Error(req.OperationID, errMsg)
|
|
|
|
//log.Error(req.OperationID, errMsg)
|
|
|
|
return &pbGroup.MuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
|
|
|
//return &pbGroup.MuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
|
|
|
|
|
|
|
SetErrorForResp(constant.ErrAccess, resp.CommonResp)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//mutedInfo, err := imdb.GetGroupMemberInfoByGroupIDAndUserID(req.GroupID, req.UserID)
|
|
|
|
//mutedInfo, err := imdb.GetGroupMemberInfoByGroupIDAndUserID(req.GroupID, req.UserID)
|
|
|
@ -1465,33 +1469,35 @@ func (s *groupServer) MuteGroup(ctx context.Context, req *pbGroup.MuteGroupReq)
|
|
|
|
// return &pbGroup.MuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
|
|
|
// return &pbGroup.MuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
|
|
|
//}
|
|
|
|
//}
|
|
|
|
if err := rocksCache.DelGroupInfoFromCache(req.GroupID); err != nil {
|
|
|
|
if err := rocksCache.DelGroupInfoFromCache(req.GroupID); err != nil {
|
|
|
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
|
|
|
SetErrorForResp(err, resp.CommonResp)
|
|
|
|
return &pbGroup.MuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}}, nil
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
err = imdb.OperateGroupStatus(req.GroupID, constant.GroupStatusMuted)
|
|
|
|
err = imdb.OperateGroupStatus(req.GroupID, constant.GroupStatusMuted)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Error(req.OperationID, "OperateGroupStatus failed ", err.Error(), req.GroupID, constant.GroupStatusMuted)
|
|
|
|
SetErrorForResp(err, resp.CommonResp)
|
|
|
|
return &pbGroup.MuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
chat.GroupMutedNotification(req.OperationID, req.OpUserID, req.GroupID)
|
|
|
|
chat.GroupMutedNotification(req.OperationID, req.OpUserID, req.GroupID)
|
|
|
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""})
|
|
|
|
return
|
|
|
|
return &pbGroup.MuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMuteGroupReq) (*pbGroup.CancelMuteGroupResp, error) {
|
|
|
|
func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMuteGroupReq) (resp *pbGroup.CancelMuteGroupResp, _ error) {
|
|
|
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc args ", req.String())
|
|
|
|
resp = &pbGroup.CancelMuteGroupResp{CommonResp: &open_im_sdk.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)
|
|
|
|
|
|
|
|
}()
|
|
|
|
opFlag, err := s.getGroupUserLevel(req.GroupID, req.OpUserID)
|
|
|
|
opFlag, err := s.getGroupUserLevel(req.GroupID, req.OpUserID)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
errMsg := req.OperationID + " getGroupUserLevel failed " + req.GroupID + req.OpUserID + err.Error()
|
|
|
|
SetErrorForResp(err, resp.CommonResp)
|
|
|
|
log.Error(req.OperationID, errMsg)
|
|
|
|
return
|
|
|
|
return &pbGroup.CancelMuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if opFlag == 0 {
|
|
|
|
if opFlag == 0 {
|
|
|
|
errMsg := req.OperationID + "opFlag == 0 " + req.GroupID + req.OpUserID
|
|
|
|
SetErrorForResp(err, resp.CommonResp)
|
|
|
|
log.Error(req.OperationID, errMsg)
|
|
|
|
return
|
|
|
|
return &pbGroup.CancelMuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: errMsg}}, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//mutedInfo, err := imdb.GetGroupMemberInfoByGroupIDAndUserID(req.GroupID, req.)
|
|
|
|
//mutedInfo, err := imdb.GetGroupMemberInfoByGroupIDAndUserID(req.GroupID, req.)
|
|
|
|
//if err != nil {
|
|
|
|
//if err != nil {
|
|
|
@ -1508,26 +1514,28 @@ func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMu
|
|
|
|
//}
|
|
|
|
//}
|
|
|
|
log.Debug(req.OperationID, "UpdateGroupInfoDefaultZero ", req.GroupID, map[string]interface{}{"status": constant.GroupOk})
|
|
|
|
log.Debug(req.OperationID, "UpdateGroupInfoDefaultZero ", req.GroupID, map[string]interface{}{"status": constant.GroupOk})
|
|
|
|
if err := rocksCache.DelGroupInfoFromCache(req.GroupID); err != nil {
|
|
|
|
if err := rocksCache.DelGroupInfoFromCache(req.GroupID); err != nil {
|
|
|
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
|
|
|
SetErrorForResp(err, resp.CommonResp)
|
|
|
|
return &pbGroup.CancelMuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}}, nil
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
SetErrorForResp(err, resp.CommonResp)
|
|
|
|
return &pbGroup.CancelMuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
chat.GroupCancelMutedNotification(req.OperationID, req.OpUserID, req.GroupID)
|
|
|
|
chat.GroupCancelMutedNotification(req.OperationID, req.OpUserID, req.GroupID)
|
|
|
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""})
|
|
|
|
return
|
|
|
|
return &pbGroup.CancelMuteGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s *groupServer) SetGroupMemberNickname(ctx context.Context, req *pbGroup.SetGroupMemberNicknameReq) (*pbGroup.SetGroupMemberNicknameResp, error) {
|
|
|
|
func (s *groupServer) SetGroupMemberNickname(ctx context.Context, req *pbGroup.SetGroupMemberNicknameReq) (resp *pbGroup.SetGroupMemberNicknameResp, _ error) {
|
|
|
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc args ", req.String())
|
|
|
|
resp = &pbGroup.SetGroupMemberNicknameResp{CommonResp: &open_im_sdk.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)
|
|
|
|
|
|
|
|
}()
|
|
|
|
if req.OpUserID != req.UserID && !token_verify.IsManagerUserID(req.OpUserID) {
|
|
|
|
if req.OpUserID != req.UserID && !token_verify.IsManagerUserID(req.OpUserID) {
|
|
|
|
errMsg := req.OperationID + " verify failed " + req.OpUserID + req.GroupID
|
|
|
|
SetErrorForResp(constant.ErrIdentity, resp.CommonResp)
|
|
|
|
log.Error(req.OperationID, errMsg)
|
|
|
|
return
|
|
|
|
return &pbGroup.SetGroupMemberNicknameResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cbReq := &pbGroup.SetGroupMemberInfoReq{
|
|
|
|
cbReq := &pbGroup.SetGroupMemberInfoReq{
|
|
|
|
GroupID: req.GroupID,
|
|
|
|
GroupID: req.GroupID,
|
|
|
@ -1536,23 +1544,10 @@ func (s *groupServer) SetGroupMemberNickname(ctx context.Context, req *pbGroup.S
|
|
|
|
OpUserID: req.OpUserID,
|
|
|
|
OpUserID: req.OpUserID,
|
|
|
|
Nickname: &wrapperspb.StringValue{Value: req.Nickname},
|
|
|
|
Nickname: &wrapperspb.StringValue{Value: req.Nickname},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
callbackResp := CallbackBeforeSetGroupMemberInfo(cbReq)
|
|
|
|
if err := CallbackBeforeSetGroupMemberInfo(ctx, cbReq); err != nil {
|
|
|
|
if callbackResp.ErrCode != 0 {
|
|
|
|
SetErrorForResp(err, resp.CommonResp)
|
|
|
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "CallbackBeforeMemberJoinGroup resp: ", callbackResp)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if callbackResp.ActionCode != constant.ActionAllow {
|
|
|
|
|
|
|
|
if callbackResp.ErrCode == 0 {
|
|
|
|
|
|
|
|
callbackResp.ErrCode = 201
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CallbackBeforeMemberJoinGroup result", "end rpc and return", callbackResp)
|
|
|
|
|
|
|
|
return &pbGroup.SetGroupMemberNicknameResp{
|
|
|
|
|
|
|
|
CommonResp: &pbGroup.CommonResp{
|
|
|
|
|
|
|
|
ErrCode: int32(callbackResp.ErrCode),
|
|
|
|
|
|
|
|
ErrMsg: callbackResp.ErrMsg,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nickName := cbReq.Nickname.Value
|
|
|
|
nickName := cbReq.Nickname.Value
|
|
|
|
groupMemberInfo := imdb.GroupMember{}
|
|
|
|
groupMemberInfo := imdb.GroupMember{}
|
|
|
|
groupMemberInfo.UserID = req.UserID
|
|
|
|
groupMemberInfo.UserID = req.UserID
|
|
|
@ -1560,9 +1555,8 @@ func (s *groupServer) SetGroupMemberNickname(ctx context.Context, req *pbGroup.S
|
|
|
|
if nickName == "" {
|
|
|
|
if nickName == "" {
|
|
|
|
userNickname, err := imdb.GetUserNameByUserID(groupMemberInfo.UserID)
|
|
|
|
userNickname, err := imdb.GetUserNameByUserID(groupMemberInfo.UserID)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
errMsg := req.OperationID + " GetUserNameByUserID failed " + err.Error()
|
|
|
|
SetErrorForResp(err, resp.CommonResp)
|
|
|
|
log.Error(req.OperationID, errMsg)
|
|
|
|
return
|
|
|
|
return &pbGroup.SetGroupMemberNicknameResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
groupMemberInfo.Nickname = userNickname
|
|
|
|
groupMemberInfo.Nickname = userNickname
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -1570,46 +1564,33 @@ func (s *groupServer) SetGroupMemberNickname(ctx context.Context, req *pbGroup.S
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.UserID); err != nil {
|
|
|
|
if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.UserID); err != nil {
|
|
|
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
|
|
|
SetErrorForResp(err, resp.CommonResp)
|
|
|
|
return &pbGroup.SetGroupMemberNicknameResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}}, nil
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
err := imdb.UpdateGroupMemberInfo(groupMemberInfo)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
if err := imdb.UpdateGroupMemberInfo(groupMemberInfo); err != nil {
|
|
|
|
errMsg := req.OperationID + " UpdateGroupMemberInfo failed " + err.Error()
|
|
|
|
SetErrorForResp(err, resp.CommonResp)
|
|
|
|
log.Error(req.OperationID, errMsg)
|
|
|
|
return
|
|
|
|
return &pbGroup.SetGroupMemberNicknameResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
chat.GroupMemberInfoSetNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID)
|
|
|
|
chat.GroupMemberInfoSetNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID)
|
|
|
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "rpc return ", pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""})
|
|
|
|
return
|
|
|
|
return &pbGroup.SetGroupMemberNicknameResp{CommonResp: &pbGroup.CommonResp{ErrCode: 0, ErrMsg: ""}}, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGroupMemberInfoReq) (resp *pbGroup.SetGroupMemberInfoResp, err error) {
|
|
|
|
func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGroupMemberInfoReq) (resp *pbGroup.SetGroupMemberInfoResp, _ error) {
|
|
|
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
|
|
|
resp = &pbGroup.SetGroupMemberInfoResp{CommonResp: &open_im_sdk.CommonResp{}}
|
|
|
|
resp = &pbGroup.SetGroupMemberInfoResp{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)
|
|
|
|
|
|
|
|
}()
|
|
|
|
if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.UserID); err != nil {
|
|
|
|
if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, req.UserID); err != nil {
|
|
|
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
|
|
|
SetErrorForResp(err, resp.CommonResp)
|
|
|
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
|
|
|
return
|
|
|
|
resp.CommonResp.ErrMsg = err.Error()
|
|
|
|
|
|
|
|
return resp, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
callbackResp := CallbackBeforeSetGroupMemberInfo(req)
|
|
|
|
|
|
|
|
if callbackResp.ErrCode != 0 {
|
|
|
|
|
|
|
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "CallbackBeforeMemberJoinGroup resp: ", callbackResp)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if callbackResp.ActionCode != constant.ActionAllow {
|
|
|
|
|
|
|
|
if callbackResp.ErrCode == 0 {
|
|
|
|
|
|
|
|
callbackResp.ErrCode = 201
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CallbackBeforeMemberJoinGroup result", "end rpc and return", callbackResp)
|
|
|
|
if err := CallbackBeforeSetGroupMemberInfo(ctx, req); err != nil {
|
|
|
|
return &pbGroup.SetGroupMemberInfoResp{
|
|
|
|
SetErrorForResp(err, resp.CommonResp)
|
|
|
|
CommonResp: &pbGroup.CommonResp{
|
|
|
|
return
|
|
|
|
ErrCode: int32(callbackResp.ErrCode),
|
|
|
|
|
|
|
|
ErrMsg: callbackResp.ErrMsg,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
groupMember := imdb.GroupMember{
|
|
|
|
groupMember := imdb.GroupMember{
|
|
|
|
GroupID: req.GroupID,
|
|
|
|
GroupID: req.GroupID,
|
|
|
|
UserID: req.UserID,
|
|
|
|
UserID: req.UserID,
|
|
|
@ -1629,12 +1610,9 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
m["ex"] = nil
|
|
|
|
m["ex"] = nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
err = imdb.UpdateGroupMemberInfoByMap(groupMember, m)
|
|
|
|
if err := imdb.UpdateGroupMemberInfoByMap(groupMember, m);err != nil {
|
|
|
|
if err != nil {
|
|
|
|
SetErrorForResp(err, resp.CommonResp)
|
|
|
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetGroupMemberInfo failed", err.Error())
|
|
|
|
return
|
|
|
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
|
|
|
|
|
|
|
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg + ":" + err.Error()
|
|
|
|
|
|
|
|
return resp, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if req.RoleLevel != nil {
|
|
|
|
if req.RoleLevel != nil {
|
|
|
|
switch req.RoleLevel.Value {
|
|
|
|
switch req.RoleLevel.Value {
|
|
|
@ -1648,30 +1626,28 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
chat.GroupMemberInfoSetNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID)
|
|
|
|
chat.GroupMemberInfoSetNotification(req.OperationID, req.OpUserID, req.GroupID, req.UserID)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
|
|
|
return
|
|
|
|
return resp, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (s *groupServer) GetGroupAbstractInfo(ctx 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(ctx, req.GroupID)
|
|
|
|
num, err := rocksCache.GetGroupMemberNumFromCache(ctx, 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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|