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

This commit is contained in:
withchao
2023-02-01 15:44:47 +08:00
51 changed files with 1408 additions and 2008 deletions
@@ -1,14 +1,5 @@
package api_struct
//UserID string `protobuf:"bytes,1,opt,name=UserID" json:"UserID,omitempty"`
// Nickname string `protobuf:"bytes,2,opt,name=Nickname" json:"Nickname,omitempty"`
// FaceUrl string `protobuf:"bytes,3,opt,name=FaceUrl" json:"FaceUrl,omitempty"`
// Gender int32 `protobuf:"varint,4,opt,name=Gender" json:"Gender,omitempty"`
// PhoneNumber string `protobuf:"bytes,5,opt,name=PhoneNumber" json:"PhoneNumber,omitempty"`
// Birth string `protobuf:"bytes,6,opt,name=Birth" json:"Birth,omitempty"`
// Email string `protobuf:"bytes,7,opt,name=Email" json:"Email,omitempty"`
// Ex string `protobuf:"bytes,8,opt,name=Ex" json:"Ex,omitempty"`
type UserRegisterReq struct {
Secret string `json:"secret" binding:"required,max=32"`
Platform int32 `json:"platform" binding:"required,min=1,max=12"`
+30
View File
@@ -0,0 +1,30 @@
package api_struct
import (
"net/http"
"github.com/gin-gonic/gin"
)
type ApiUserInfo struct {
UserID string `json:"userID" binding:"required,min=1,max=64" swaggo:"true,用户ID,"`
Nickname string `json:"nickname" binding:"omitempty,min=1,max=64" swaggo:"true,my id,19"`
FaceURL string `json:"faceURL" binding:"omitempty,max=1024"`
Gender int32 `json:"gender" binding:"omitempty,oneof=0 1 2"`
PhoneNumber string `json:"phoneNumber" binding:"omitempty,max=32"`
Birth int64 `json:"birth" binding:"omitempty"`
Email string `json:"email" binding:"omitempty,max=64"`
CreateTime int64 `json:"createTime"`
Ex string `json:"ex" binding:"omitempty,max=1024"`
}
type GroupAddMemberInfo struct {
UserID string `json:"userID" binding:"required"`
RoleLevel int32 `json:"roleLevel" binding:"required,oneof= 1 3"`
}
func SetErrCodeMsg(c *gin.Context, status int) *CommResp {
resp := CommResp{ErrCode: int32(status), ErrMsg: http.StatusText(status)}
c.JSON(status, resp)
return &resp
}
-143
View File
@@ -1,143 +0,0 @@
package api_struct
import (
"net/http"
"github.com/gin-gonic/gin"
)
type ApiUserInfo struct {
UserID string `json:"userID" binding:"required,min=1,max=64" swaggo:"true,用户ID,"`
Nickname string `json:"nickname" binding:"omitempty,min=1,max=64" swaggo:"true,my id,19"`
FaceURL string `json:"faceURL" binding:"omitempty,max=1024"`
Gender int32 `json:"gender" binding:"omitempty,oneof=0 1 2"`
PhoneNumber string `json:"phoneNumber" binding:"omitempty,max=32"`
Birth uint32 `json:"birth" binding:"omitempty"`
Email string `json:"email" binding:"omitempty,max=64"`
CreateTime int64 `json:"createTime"`
LoginLimit int32 `json:"loginLimit" binding:"omitempty"`
Ex string `json:"ex" binding:"omitempty,max=1024"`
BirthStr string `json:"birthStr" binding:"omitempty"`
}
//type Conversation struct {
// OwnerUserID string `gorm:"column:owner_user_id;primary_key;type:char(128)" json:"OwnerUserID"`
// ConversationID string `gorm:"column:conversation_id;primary_key;type:char(128)" json:"conversationID"`
// ConversationType int32 `gorm:"column:conversation_type" json:"conversationType"`
// UserID string `gorm:"column:user_id;type:char(64)" json:"userID"`
// GroupID string `gorm:"column:group_id;type:char(128)" json:"groupID"`
// RecvMsgOpt int32 `gorm:"column:recv_msg_opt" json:"recvMsgOpt"`
// UnreadCount int32 `gorm:"column:unread_count" json:"unreadCount"`
// DraftTextTime int64 `gorm:"column:draft_text_time" json:"draftTextTime"`
// IsPinned bool `gorm:"column:is_pinned" json:"isPinned"`
// AttachedInfo string `gorm:"column:attached_info;type:varchar(1024)" json:"attachedInfo"`
// Ex string `gorm:"column:ex;type:varchar(1024)" json:"ex"`
//}
type GroupAddMemberInfo struct {
UserID string `json:"userID" binding:"required"`
RoleLevel int32 `json:"roleLevel" binding:"required,oneof= 1 3"`
}
func SetErrCodeMsg(c *gin.Context, status int) *CommResp {
resp := CommResp{ErrCode: int32(status), ErrMsg: http.StatusText(status)}
c.JSON(status, resp)
return &resp
}
//GroupName string `json:"groupName"`
// Introduction string `json:"introduction"`
// Notification string `json:"notification"`
// FaceUrl string `json:"faceUrl"`
// OperationID string `json:"operationID" binding:"required"`
// GroupType int32 `json:"groupType"`
// Ex string `json:"ex"`
//type GroupInfo struct {
// GroupID string `json:"groupID"`
// GroupName string `json:"groupName"`
// Notification string `json:"notification"`
// Introduction string `json:"introduction"`
// FaceUrl string `json:"faceUrl"`
// OwnerUserID string `json:"ownerUserID"`
// Ex string `json:"ex"`
// GroupType int32 `json:"groupType"`
//}
//type GroupMemberFullInfo struct {
// GroupID string `json:"groupID"`
// UserID string `json:"userID"`
// RoleLevel int32 `json:"roleLevel"`
// JoinTime uint64 `json:"joinTime"`
// Nickname string `json:"nickname"`
// FaceUrl string `json:"faceUrl"`
// FriendRemark string `json:"friendRemark"`
// AppMangerLevel int32 `json:"appMangerLevel"`
// JoinSource int32 `json:"joinSource"`
// OperatorUserID string `json:"operatorUserID"`
// Ex string `json:"ex"`
//}
//
//type PublicUserInfo struct {
// UserID string `json:"userID"`
// Nickname string `json:"nickname"`
// FaceUrl string `json:"faceUrl"`
// Gender int32 `json:"gender"`
//}
//
//type UserInfo struct {
// UserID string `json:"userID"`
// Nickname string `json:"nickname"`
// FaceUrl string `json:"faceUrl"`
// Gender int32 `json:"gender"`
// Mobile string `json:"mobile"`
// Birth string `json:"birth"`
// Email string `json:"email"`
// Ex string `json:"ex"`
//}
//
//type FriendInfo struct {
// OwnerUserID string `json:"ownerUserID"`
// Remark string `json:"remark"`
// CreateTime int64 `json:"createTime"`
// FriendUser UserInfo `json:"friendUser"`
// AddSource int32 `json:"addSource"`
// OperatorUserID string `json:"operatorUserID"`
// Ex string `json:"ex"`
//}
//
//type BlackInfo struct {
// OwnerUserID string `json:"ownerUserID"`
// CreateTime int64 `json:"createTime"`
// BlackUser PublicUserInfo `json:"friendUser"`
// AddSource int32 `json:"addSource"`
// OperatorUserID string `json:"operatorUserID"`
// Ex string `json:"ex"`
//}
//
//type GroupRequest struct {
// UserID string `json:"userID"`
// GroupID string `json:"groupID"`
// HandleResult string `json:"handleResult"`
// ReqMsg string `json:"reqMsg"`
// HandleMsg string `json:"handleMsg"`
// ReqTime int64 `json:"reqTime"`
// HandleUserID string `json:"handleUserID"`
// HandleTime int64 `json:"handleTime"`
// Ex string `json:"ex"`
//}
//
//type FriendRequest struct {
// FromUserID string `json:"fromUserID"`
// ToUserID string `json:"toUserID"`
// HandleResult int32 `json:"handleResult"`
// ReqMessage string `json:"reqMessage"`
// CreateTime int64 `json:"createTime"`
// HandlerUserID string `json:"handlerUserID"`
// HandleMsg string `json:"handleMsg"`
// HandleTime int64 `json:"handleTime"`
// Ex string `json:"ex"`
//}
//
//
//
-15
View File
@@ -1,21 +1,6 @@
package constant
const (
//group admin
// OrdinaryMember = 0
// GroupOwner = 1
// Administrator = 2
//group application
// Application = 0
// AgreeApplication = 1
//friend related
BlackListFlag = 1
ApplicationFriendFlag = 0
FriendFlag = 1
RefuseFriendFlag = -1
//Websocket Protocol
WSGetNewestSeq = 1001
WSPullMsgBySeqList = 1002
-28
View File
@@ -1,10 +1,7 @@
package constant
import (
sdkws "Open_IM/pkg/proto/sdk_ws"
"context"
"encoding/json"
"fmt"
"github.com/pkg/errors"
"gorm.io/gorm"
"strings"
@@ -67,28 +64,3 @@ func ToAPIErrWithErr(err error) *ErrInfo {
}
return toDetail(err, ErrDefaultOther)
}
func SetErrorForResp(err error, commonResp *sdkws.CommonResp) {
errInfo := ToAPIErrWithErr(err)
commonResp.ErrCode = errInfo.ErrCode
commonResp.ErrMsg = errInfo.ErrMsg
commonResp.DetailErrMsg = err.Error()
}
func CommonResp2Err(resp *sdkws.CommonResp) error {
if resp.ErrCode != NoError {
return errors.New(fmt.Sprintf("call rpc error, errCode is %d, errMsg is %s, detailErrMsg is %s", resp.ErrCode, resp.ErrMsg, resp.DetailErrMsg))
}
return nil
}
func Error2CommResp(ctx context.Context, info *ErrInfo, detailErrMsg string) *sdkws.CommonResp {
err := &sdkws.CommonResp{
ErrCode: info.ErrCode,
ErrMsg: info.ErrMsg,
}
if detailErrMsg != "" {
err.DetailErrMsg = detailErrMsg
}
return err
}
+297 -15
View File
@@ -1,36 +1,92 @@
package cache
import (
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db/relation"
"Open_IM/pkg/common/db/unrelation"
"Open_IM/pkg/common/tracelog"
"Open_IM/pkg/utils"
"context"
"encoding/json"
"github.com/dtm-labs/rockscache"
"github.com/go-redis/redis/v8"
"math/big"
"sort"
"strconv"
"sync"
"time"
)
const GroupExpireTime = time.Second * 60 * 60 * 12
const groupInfoCacheKey = "GROUP_INFO_CACHE:"
const (
groupExpireTime = time.Second * 60 * 60 * 12
groupInfoKey = "GROUP_INFO:"
groupMemberIDsKey = "GROUP_MEMBER_IDS:"
groupMembersHashKey = "GROUP_MEMBERS_HASH:"
groupMemberInfoKey = "GROUP_MEMBER_INFO:"
joinedSuperGroupsKey = "JOIN_SUPER_GROUPS:"
joinedGroupsKey = "JOIN_GROUPS_KEY:"
groupMemberNumKey = "GROUP_MEMBER_NUM_CACHE:"
)
type GroupCache struct {
group *relation.Group
groupMember *relation.GroupMember
groupRequest *relation.GroupRequest
mongoDB *unrelation.SuperGroupMgoDB
expireTime time.Duration
redisClient *RedisClient
rcClient *rockscache.Client
//local cache
cacheGroupMtx sync.RWMutex
cacheGroupMemberUserIDs map[string]*GroupMemberIDsHash
}
func NewGroupCache(rdb redis.UniversalClient, groupDB *relation.Group, groupMemberDB *relation.GroupMember, groupRequestDB *relation.GroupRequest, opts rockscache.Options) *GroupCache {
return &GroupCache{rcClient: rockscache.NewClient(rdb, opts), expireTime: GroupExpireTime, group: groupDB, groupMember: groupMemberDB, groupRequest: groupRequestDB, redisClient: NewRedisClient(rdb)}
type GroupMemberIDsHash struct {
MemberListHash uint64
UserIDs []string
}
func NewGroupCache(rdb redis.UniversalClient, groupDB *relation.Group, groupMemberDB *relation.GroupMember, groupRequestDB *relation.GroupRequest, mongoClient *unrelation.SuperGroupMgoDB, opts rockscache.Options) *GroupCache {
return &GroupCache{rcClient: rockscache.NewClient(rdb, opts), expireTime: groupExpireTime,
group: groupDB, groupMember: groupMemberDB, groupRequest: groupRequestDB, redisClient: NewRedisClient(rdb),
mongoDB: mongoClient, cacheGroupMemberUserIDs: make(map[string]*GroupMemberIDsHash, 0),
}
}
func (g *GroupCache) getRedisClient() *RedisClient {
return g.redisClient
}
func (g *GroupCache) getGroupInfoKey(groupID string) string {
return groupInfoKey + groupID
}
func (g *GroupCache) getJoinedSuperGroupsIDKey(userID string) string {
return joinedSuperGroupsKey + userID
}
func (g *GroupCache) getJoinedGroupsKey(userID string) string {
return joinedGroupsKey + userID
}
func (g *GroupCache) getGroupMembersHashKey(groupID string) string {
return groupMembersHashKey + groupID
}
func (g *GroupCache) getGroupMemberIDsKey(groupID string) string {
return groupMemberIDsKey + groupID
}
func (g *GroupCache) getGroupMemberInfoKey(groupID, userID string) string {
return groupMemberInfoKey + groupID + "-" + userID
}
func (g *GroupCache) getGroupMemberNumKey(groupID string) string {
return groupMemberNumKey + groupID
}
/// groupInfo
func (g *GroupCache) GetGroupsInfo(ctx context.Context, groupIDs []string) (groups []*relation.Group, err error) {
for _, groupID := range groupIDs {
group, err := g.GetGroupInfo(ctx, groupID)
@@ -58,9 +114,9 @@ func (g *GroupCache) GetGroupInfo(ctx context.Context, groupID string) (group *r
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "group", *group)
}()
groupStr, err := g.rcClient.Fetch(g.getGroupInfoCacheKey(groupID), g.expireTime, getGroup)
groupStr, err := g.rcClient.Fetch(g.getGroupInfoKey(groupID), g.expireTime, getGroup)
if err != nil {
return nil, utils.Wrap(err, "")
return nil, err
}
err = json.Unmarshal([]byte(groupStr), group)
return group, utils.Wrap(err, "")
@@ -70,7 +126,7 @@ func (g *GroupCache) DelGroupInfo(ctx context.Context, groupID string) (err erro
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID)
}()
return g.rcClient.TagAsDeleted(g.getGroupInfoCacheKey(groupID))
return g.rcClient.TagAsDeleted(g.getGroupInfoKey(groupID))
}
func (g *GroupCache) DelGroupsInfo(ctx context.Context, groupIDs []string) error {
@@ -82,21 +138,247 @@ func (g *GroupCache) DelGroupsInfo(ctx context.Context, groupIDs []string) error
return nil
}
func (g *GroupCache) getGroupInfoCacheKey(groupID string) string {
return groupInfoCacheKey + groupID
}
func (g *GroupCache) DelJoinedSuperGroupIDs(ctx context.Context, userIDs []string) (err error) {
// userJoinSuperGroup
func (g *GroupCache) BatchDelJoinedSuperGroupIDs(ctx context.Context, userIDs []string) (err error) {
for _, userID := range userIDs {
if err := g.rcClient.TagAsDeleted(joinedSuperGroupListCache + userID); err != nil {
if err := g.DelJoinedSuperGroupIDs(ctx, userID); err != nil {
return err
}
}
return nil
}
func (g *GroupCache) DelJoinedSuperGroupID(ctx context.Context, userID string) (err error) {
func (g *GroupCache) DelJoinedSuperGroupIDs(ctx context.Context, userID string) (err error) {
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID)
}()
return g.rcClient.TagAsDeleted(joinedSuperGroupListCache + userID)
return g.rcClient.TagAsDeleted(g.getJoinedSuperGroupsIDKey(userID))
}
func (g *GroupCache) GetJoinedSuperGroupIDs(ctx context.Context, userID string) (joinedSuperGroupIDs []string, err error) {
getJoinedSuperGroupIDList := func() (string, error) {
userToSuperGroup, err := g.mongoDB.GetSuperGroupByUserID(ctx, userID)
if err != nil {
return "", err
}
bytes, err := json.Marshal(userToSuperGroup.GroupIDList)
if err != nil {
return "", utils.Wrap(err, "")
}
return string(bytes), nil
}
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "joinedSuperGroupIDs", joinedSuperGroupIDs)
}()
joinedSuperGroupListStr, err := g.rcClient.Fetch(g.getJoinedSuperGroupsIDKey(userID), time.Second*30*60, getJoinedSuperGroupIDList)
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(joinedSuperGroupListStr), &joinedSuperGroupIDs)
return joinedSuperGroupIDs, utils.Wrap(err, "")
}
// groupMembersHash
func (g *GroupCache) GetGroupMembersHash(ctx context.Context, groupID string) (hashCodeUint64 uint64, err error) {
generateHash := func() (string, error) {
groupInfo, err := g.GetGroupInfo(ctx, groupID)
if err != nil {
return "", err
}
if groupInfo.Status == constant.GroupStatusDismissed {
return "0", nil
}
groupMemberIDList, err := g.GetGroupMemberIDs(ctx, groupID)
if err != nil {
return "", err
}
sort.Strings(groupMemberIDList)
var all string
for _, v := range groupMemberIDList {
all += v
}
bi := big.NewInt(0)
bi.SetString(utils.Md5(all)[0:8], 16)
return strconv.Itoa(int(bi.Uint64())), nil
}
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "hashCodeUint64", hashCodeUint64)
}()
hashCodeStr, err := g.rcClient.Fetch(g.getGroupMembersHashKey(groupID), time.Second*30*60, generateHash)
if err != nil {
return 0, utils.Wrap(err, "fetch failed")
}
hashCode, err := strconv.Atoi(hashCodeStr)
return uint64(hashCode), err
}
func (g *GroupCache) DelGroupMembersHash(ctx context.Context, groupID string) (err error) {
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID)
}()
return g.rcClient.TagAsDeleted(g.getGroupMembersHashKey(groupID))
}
// groupMemberIDs
// from redis
func (g *GroupCache) GetGroupMemberIDs(ctx context.Context, groupID string) (groupMemberIDs []string, err error) {
f := func() (string, error) {
groupInfo, err := g.GetGroupInfo(ctx, groupID)
if err != nil {
return "", err
}
var groupMemberIDList []string
if groupInfo.GroupType == constant.SuperGroup {
superGroup, err := g.mongoDB.GetSuperGroup(ctx, groupID)
if err != nil {
return "", err
}
groupMemberIDList = superGroup.MemberIDList
} else {
groupMemberIDList, err = relation.GetGroupMemberIDListByGroupID(groupID)
if err != nil {
return "", err
}
}
bytes, err := json.Marshal(groupMemberIDList)
if err != nil {
return "", utils.Wrap(err, "")
}
return string(bytes), nil
}
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "groupMemberIDList", groupMemberIDs)
}()
groupIDListStr, err := g.rcClient.Fetch(g.getGroupMemberIDsKey(groupID), time.Second*30*60, f)
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(groupIDListStr), &groupMemberIDs)
return groupMemberIDs, nil
}
func (g *GroupCache) DelGroupMemberIDs(ctx context.Context, groupID string) (err error) {
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID)
}()
return g.rcClient.TagAsDeleted(g.getGroupMemberIDsKey(groupID))
}
// from local map
func (g *GroupCache) LocalGetGroupMemberIDs(ctx context.Context, groupID string) (groupMemberIDs []string, err error) {
remoteHash, err := g.GetGroupMembersHash(ctx, groupID)
if err != nil {
g.cacheGroupMtx.Lock()
defer g.cacheGroupMtx.Unlock()
delete(g.cacheGroupMemberUserIDs, groupID)
return nil, err
}
g.cacheGroupMtx.Lock()
defer g.cacheGroupMtx.Unlock()
if remoteHash == 0 {
delete(g.cacheGroupMemberUserIDs, groupID)
return []string{}, nil
}
localCache, ok := g.cacheGroupMemberUserIDs[groupID]
if ok && localCache.MemberListHash == remoteHash {
return localCache.UserIDs, nil
}
groupMemberIDsRemote, err := g.GetGroupMemberIDs(ctx, groupID)
if err != nil {
return nil, err
}
g.cacheGroupMemberUserIDs[groupID] = &GroupMemberIDsHash{
MemberListHash: remoteHash,
UserIDs: groupMemberIDsRemote,
}
return groupMemberIDsRemote, nil
}
// JoinedGroups
func (g *GroupCache) GetJoinedGroupIDs(ctx context.Context, userID string) (joinedGroupIDs []string, err error) {
getJoinedGroupIDList := func() (string, error) {
joinedGroupList, err := relation.GetJoinedGroupIDListByUserID(userID)
if err != nil {
return "", err
}
bytes, err := json.Marshal(joinedGroupList)
if err != nil {
return "", utils.Wrap(err, "")
}
return string(bytes), nil
}
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "joinedGroupIDs", joinedGroupIDs)
}()
joinedGroupIDListStr, err := g.rcClient.Fetch(g.getJoinedGroupsKey(userID), time.Second*30*60, getJoinedGroupIDList)
if err != nil {
return nil, err
}
err = json.Unmarshal([]byte(joinedGroupIDListStr), &joinedGroupIDs)
return joinedGroupIDs, utils.Wrap(err, "")
}
func (g *GroupCache) DelJoinedGroupIDs(ctx context.Context, userID string) (err error) {
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID)
}()
return g.rcClient.TagAsDeleted(g.getJoinedGroupsKey(userID))
}
// GetGroupMemberInfo
func (g *GroupCache) GetGroupMemberInfo(ctx context.Context, groupID, userID string) (groupMember *relation.GroupMember, err error) {
getGroupMemberInfo := func() (string, error) {
groupMemberInfo, err := relation.GetGroupMemberInfoByGroupIDAndUserID(groupID, userID)
if err != nil {
return "", err
}
bytes, err := json.Marshal(groupMemberInfo)
if err != nil {
return "", utils.Wrap(err, "")
}
return string(bytes), nil
}
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID, "groupMember", *groupMember)
}()
groupMemberInfoStr, err := g.rcClient.Fetch(g.getGroupMemberInfoKey(groupID, userID), time.Second*30*60, getGroupMemberInfo)
if err != nil {
return nil, err
}
groupMember = &relation.GroupMember{}
err = json.Unmarshal([]byte(groupMemberInfoStr), groupMember)
return groupMember, utils.Wrap(err, "")
}
func (g *GroupCache) DelGroupMemberInfo(ctx context.Context, groupID, userID string) (err error) {
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "userID", userID)
}()
return g.rcClient.TagAsDeleted(g.getGroupMemberInfoKey(groupID, userID))
}
// groupMemberNum
func (g *GroupCache) GetGroupMemberNum(ctx context.Context, groupID string) (num int, err error) {
getGroupMemberNum := func() (string, error) {
num, err := relation.GetGroupMemberNumByGroupID(groupID)
if err != nil {
return "", err
}
return strconv.Itoa(int(num)), nil
}
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID, "num", num)
}()
groupMember, err := g.rcClient.Fetch(g.getGroupMemberNumKey(groupID), time.Second*30*60, getGroupMemberNum)
if err != nil {
return 0, err
}
return strconv.Atoi(groupMember)
}
func (g *GroupCache) DelGroupMemberNum(ctx context.Context, groupID string) (err error) {
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "groupID", groupID)
}()
return g.rcClient.TagAsDeleted(g.getGroupMemberNumKey(groupID))
}
+18 -16
View File
@@ -4,6 +4,7 @@ import (
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db/mongo"
"Open_IM/pkg/common/db/mysql"
"Open_IM/pkg/common/db/relation"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/tracelog"
"Open_IM/pkg/utils"
@@ -19,31 +20,32 @@ import (
)
const (
userInfoCache = "USER_INFO_CACHE:"
//userInfoCache = "USER_INFO_CACHE:"
friendRelationCache = "FRIEND_RELATION_CACHE:"
blackListCache = "BLACK_LIST_CACHE:"
groupCache = "GROUP_CACHE:"
//groupCache = "GROUP_CACHE:"
//groupInfoCache = "GROUP_INFO_CACHE:"
groupOwnerIDCache = "GROUP_OWNER_ID:"
joinedGroupListCache = "JOINED_GROUP_LIST_CACHE:"
groupMemberInfoCache = "GROUP_MEMBER_INFO_CACHE:"
groupAllMemberInfoCache = "GROUP_ALL_MEMBER_INFO_CACHE:"
allFriendInfoCache = "ALL_FRIEND_INFO_CACHE:"
joinedSuperGroupListCache = "JOINED_SUPER_GROUP_LIST_CACHE:"
groupMemberListHashCache = "GROUP_MEMBER_LIST_HASH_CACHE:"
groupMemberNumCache = "GROUP_MEMBER_NUM_CACHE:"
conversationCache = "CONVERSATION_CACHE:"
conversationIDListCache = "CONVERSATION_ID_LIST_CACHE:"
extendMsgSetCache = "EXTEND_MSG_SET_CACHE:"
extendMsgCache = "EXTEND_MSG_CACHE:"
//groupOwnerIDCache = "GROUP_OWNER_ID:"
//joinedGroupListCache = "JOINED_GROUP_LIST_CACHE:"
//groupMemberInfoCache = "GROUP_MEMBER_INFO_CACHE:"
//groupAllMemberInfoCache = "GROUP_ALL_MEMBER_INFO_CACHE:"
allFriendInfoCache = "ALL_FRIEND_INFO_CACHE:"
//joinedSuperGroupListCache = "JOINED_SUPER_GROUP_LIST_CACHE:"
//groupMemberListHashCache = "GROUP_MEMBER_LIST_HASH_CACHE:"
//groupMemberNumCache = "GROUP_MEMBER_NUM_CACHE:"
conversationCache = "CONVERSATION_CACHE:"
conversationIDListCache = "CONVERSATION_ID_LIST_CACHE:"
extendMsgSetCache = "EXTEND_MSG_SET_CACHE:"
extendMsgCache = "EXTEND_MSG_CACHE:"
)
const scanCount = 3000
const RandomExpireAdjustment = 0.2
func (rc *RcClient) DelKeys() {
for _, key := range []string{groupCache, friendRelationCache, blackListCache, userInfoCache, groupInfoCacheKey, groupOwnerIDCache, joinedGroupListCache,
groupMemberInfoCache, groupAllMemberInfoCache, allFriendInfoCache} {
for _, key := range []string{"GROUP_CACHE:", "FRIEND_RELATION_CACHE", "BLACK_LIST_CACHE:", "USER_INFO_CACHE:", "GROUP_INFO_CACHE", groupOwnerIDCache, joinedGroupListCache,
groupMemberInfoCache, groupAllMemberInfoCache, "ALL_FRIEND_INFO_CACHE:"} {
fName := utils.GetSelfFuncName()
var cursor uint64
var n int
+90
View File
@@ -0,0 +1,90 @@
package cache
import (
"Open_IM/pkg/common/db/relation"
"Open_IM/pkg/common/tracelog"
"Open_IM/pkg/utils"
"context"
"encoding/json"
"github.com/dtm-labs/rockscache"
"github.com/go-redis/redis/v8"
"time"
)
const (
UserExpireTime = time.Second * 60 * 60 * 12
userInfoKey = "USER_INFO:"
)
type UserCache struct {
userDB *relation.User
expireTime time.Duration
redisClient *RedisClient
rcClient *rockscache.Client
}
func NewUserCache(rdb redis.UniversalClient, userDB *relation.User, options rockscache.Options) *UserCache {
return &UserCache{
userDB: userDB,
expireTime: UserExpireTime,
redisClient: NewRedisClient(rdb),
rcClient: rockscache.NewClient(rdb, options),
}
}
func (u *UserCache) getUserInfoKey(userID string) string {
return userInfoKey + userID
}
func (u *UserCache) GetUserInfo(ctx context.Context, userID string) (userInfo *relation.User, err error) {
getUserInfo := func() (string, error) {
userInfo, err := u.userDB.Take(ctx, userID)
if err != nil {
return "", err
}
bytes, err := json.Marshal(userInfo)
if err != nil {
return "", utils.Wrap(err, "")
}
return string(bytes), nil
}
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID, "userInfo", *userInfo)
}()
userInfoStr, err := u.rcClient.Fetch(u.getUserInfoKey(userID), time.Second*30*60, getUserInfo)
if err != nil {
return nil, err
}
userInfo = &relation.User{}
err = json.Unmarshal([]byte(userInfoStr), userInfo)
return userInfo, utils.Wrap(err, "")
}
func (u *UserCache) GetUsersInfo(ctx context.Context, userIDs []string) ([]*relation.User, error) {
var users []*relation.User
for _, userID := range userIDs {
user, err := GetUserInfoFromCache(ctx, userID)
if err != nil {
return nil, err
}
users = append(users, user)
}
return users, nil
}
func (u *UserCache) DelUserInfo(ctx context.Context, userID string) (err error) {
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID)
}()
return u.rcClient.TagAsDeleted(u.getUserInfoKey(userID) + userID)
}
func (u *UserCache) DelUsersInfo(ctx context.Context, userIDs []string) (err error) {
for _, userID := range userIDs {
if err := u.DelUserInfo(ctx, userID); err != nil {
return err
}
}
return nil
}
+9
View File
@@ -0,0 +1,9 @@
package controller
import "context"
type AuthInterface interface {
GetTokens(ctx context.Context, userID, platform string) (map[string]int, error)
DeleteToken(ctx context.Context, userID, platform string) error
CreateToken(ctx context.Context, userID string, platformID int, ttl int64) (string, error)
}
+37 -9
View File
@@ -3,6 +3,7 @@ package controller
import (
"Open_IM/pkg/common/db/relation"
"context"
"errors"
"gorm.io/gorm"
)
@@ -12,9 +13,9 @@ type BlackInterface interface {
// Delete 删除黑名单
Delete(ctx context.Context, blacks []*relation.Black) (err error)
// FindOwnerBlacks 获取黑名单列表
FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blackList []*relation.Black, err error)
FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blacks []*relation.Black, total int64, err error)
// CheckIn 检查user2是否在user1的黑名单列表中(inUser1Blacks==true) 检查user1是否在user2的黑名单列表中(inUser2Blacks==true)
CheckIn(ctx context.Context, ownerUserID, blackUserID string) (inUser1Blacks bool, inUser2Blacks bool, err error)
CheckIn(ctx context.Context, userID1, userID2 string) (inUser1Blacks bool, inUser2Blacks bool, err error)
}
type BlackController struct {
@@ -27,18 +28,22 @@ func NewBlackController(db *gorm.DB) *BlackController {
// Create 增加黑名单
func (b *BlackController) Create(ctx context.Context, blacks []*relation.Black) (err error) {
return b.database.Create(ctx, blacks)
}
// Delete 删除黑名单
func (b *BlackController) Delete(ctx context.Context, blacks []*relation.Black) (err error) {
return b.database.Delete(ctx, blacks)
}
// FindOwnerBlacks 获取黑名单列表
func (b *BlackController) FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blackList []*relation.Black, err error) {
func (b *BlackController) FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blackList []*relation.Black, total int64, err error) {
return b.database.FindOwnerBlacks(ctx, ownerUserID, pageNumber, showNumber)
}
// CheckIn 检查user2是否在user1的黑名单列表中(inUser1Blacks==true) 检查user1是否在user2的黑名单列表中(inUser2Blacks==true)
func (b *BlackController) CheckIn(ctx context.Context, ownerUserID, blackUserID string) (inUser1Blacks bool, inUser2Blacks bool, err error) {
func (b *BlackController) CheckIn(ctx context.Context, userID1, userID2 string) (inUser1Blacks bool, inUser2Blacks bool, err error) {
return b.database.CheckIn(ctx, userID1, userID2)
}
type BlackDatabaseInterface interface {
@@ -47,10 +52,9 @@ type BlackDatabaseInterface interface {
// Delete 删除黑名单
Delete(ctx context.Context, blacks []*relation.Black) (err error)
// FindOwnerBlacks 获取黑名单列表
FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blackList []*relation.Black, err error)
FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blacks []*relation.Black, total int64, err error)
// CheckIn 检查user2是否在user1的黑名单列表中(inUser1Blacks==true) 检查user1是否在user2的黑名单列表中(inUser2Blacks==true)
CheckIn(ctx context.Context, ownerUserID, blackUserID string) (inUser1Blacks bool, inUser2Blacks bool, err error)
}
CheckIn(ctx context.Context, userID1, userID2 string) (inUser1Blacks bool, inUser2Blacks bool, err error)
}
type BlackDatabase struct {
@@ -67,16 +71,40 @@ func NewBlackDatabase(db *gorm.DB) *BlackDatabase {
// Create 增加黑名单
func (b *BlackDatabase) Create(ctx context.Context, blacks []*relation.Black) (err error) {
return b.sqlDB.Create(ctx, blacks)
}
// Delete 删除黑名单
func (b *BlackDatabase) Delete(ctx context.Context, blacks []*relation.Black) (err error) {
return b.sqlDB.Delete(ctx, blacks)
}
// FindOwnerBlacks 获取黑名单列表
func (b *BlackDatabase) FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blackList []*relation.Black, err error) {
func (b *BlackDatabase) FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blacks []*relation.Black, total int64, err error) {
return b.sqlDB.FindOwnerBlacks(ctx, ownerUserID, pageNumber, showNumber)
}
// CheckIn 检查user2是否在user1的黑名单列表中(inUser1Blacks==true) 检查user1是否在user2的黑名单列表中(inUser2Blacks==true)
func (b *BlackDatabase) CheckIn(ctx context.Context, ownerUserID, blackUserID string) (inUser1Blacks bool, inUser2Blacks bool, err error) {
func (b *BlackDatabase) CheckIn(ctx context.Context, userID1, userID2 string) (inUser1Blacks bool, inUser2Blacks bool, err error) {
_, err = b.sqlDB.Take(ctx, userID1, userID2)
if err != nil {
if errors.Unwrap(err) != gorm.ErrRecordNotFound {
return
}
inUser1Blacks = false
} else {
inUser1Blacks = true
}
inUser2Blacks = true
_, err = b.sqlDB.Take(ctx, userID2, userID1)
if err != nil {
if errors.Unwrap(err) != gorm.ErrRecordNotFound {
return
}
inUser2Blacks = false
} else {
inUser2Blacks = true
}
return
}
+49
View File
@@ -0,0 +1,49 @@
package controller
import (
"Open_IM/pkg/common/db/relation"
pbMsg "Open_IM/pkg/proto/msg"
"gorm.io/gorm"
)
type ChatLogInterface interface {
CreateChatLog(msg pbMsg.MsgDataToMQ) error
GetChatLog(chatLog *relation.ChatLog, pageNumber, showNumber int32, contentTypeList []int32) (int64, []relation.ChatLog, error)
}
func NewChatLogController(db *gorm.DB) ChatLogInterface {
return &ChatLogController{database: NewChatLogDataBase(db)}
}
type ChatLogController struct {
database ChatLogDataBaseInterface
}
func (c *ChatLogController) CreateChatLog(msg pbMsg.MsgDataToMQ) error {
return c.database.CreateChatLog(msg)
}
func (c *ChatLogController) GetChatLog(chatLog *relation.ChatLog, pageNumber, showNumber int32, contentTypeList []int32) (int64, []relation.ChatLog, error) {
return c.database.GetChatLog(chatLog, pageNumber, showNumber, contentTypeList)
}
type ChatLogDataBaseInterface interface {
CreateChatLog(msg pbMsg.MsgDataToMQ) error
GetChatLog(chatLog *relation.ChatLog, pageNumber, showNumber int32, contentTypeList []int32) (int64, []relation.ChatLog, error)
}
type ChatLogDataBase struct {
chatLogDB *relation.ChatLog
}
func NewChatLogDataBase(db *gorm.DB) ChatLogDataBaseInterface {
return &ChatLogDataBase{chatLogDB: relation.NewChatLog(db)}
}
func (c *ChatLogDataBase) CreateChatLog(msg pbMsg.MsgDataToMQ) error {
return c.chatLogDB.Create(msg)
}
func (c *ChatLogDataBase) GetChatLog(chatLog *relation.ChatLog, pageNumber, showNumber int32, contentTypeList []int32) (int64, []relation.ChatLog, error) {
return c.chatLogDB.GetChatLog(chatLog, pageNumber, showNumber, contentTypeList)
}
+7 -6
View File
@@ -134,8 +134,8 @@ func (g *GroupController) AddUserToSuperGroup(ctx context.Context, groupID strin
panic("implement me")
}
func NewGroupController(db *gorm.DB, rdb redis.UniversalClient, mgoDB *mongo.Client) GroupInterface {
groupController := &GroupController{database: newGroupDatabase(db, rdb, mgoDB)}
func NewGroupController(db *gorm.DB, rdb redis.UniversalClient, mgoClient *mongo.Client) GroupInterface {
groupController := &GroupController{database: newGroupDatabase(db, rdb, mgoClient)}
return groupController
}
@@ -182,23 +182,24 @@ type GroupDataBase struct {
mongoDB *unrelation.SuperGroupMgoDB
}
func newGroupDatabase(db *gorm.DB, rdb redis.UniversalClient, mgoDB *mongo.Client) GroupDataBaseInterface {
func newGroupDatabase(db *gorm.DB, rdb redis.UniversalClient, mgoClient *mongo.Client) GroupDataBaseInterface {
groupDB := relation.NewGroupDB(db)
groupMemberDB := relation.NewGroupMemberDB(db)
groupRequestDB := relation.NewGroupRequest(db)
newDB := db
superGroupMgoDB := unrelation.NewSuperGroupMgoDB(mgoClient)
database := &GroupDataBase{
groupDB: groupDB,
groupMemberDB: groupMemberDB,
groupRequestDB: groupRequestDB,
db: newDB,
cache: cache.NewGroupCache(rdb, groupDB, groupMemberDB, groupRequestDB, rockscache.Options{
cache: cache.NewGroupCache(rdb, groupDB, groupMemberDB, groupRequestDB, superGroupMgoDB, rockscache.Options{
RandomExpireAdjustment: 0.2,
DisableCacheRead: false,
DisableCacheDelete: false,
StrongConsistency: true,
}),
mongoDB: unrelation.NewSuperGroupMgoDB(mgoDB),
mongoDB: superGroupMgoDB,
}
return database
}
@@ -272,7 +273,7 @@ func (g *GroupDataBase) CreateSuperGroup(ctx context.Context, groupID string, in
return err
}
if err = g.cache.DelJoinedSuperGroupIDs(ctx, initMemberIDList); err != nil {
if err = g.cache.BatchDelJoinedSuperGroupIDs(ctx, initMemberIDList); err != nil {
_ = sess.AbortTransaction(ctx)
return err
}
+3 -1
View File
@@ -7,14 +7,16 @@ import (
)
type UserInterface interface {
//获取指定用户的信息 如果有记录未找到 也返回错误
Find(ctx context.Context, userIDs []string) (users []*relation.User, err error)
Create(ctx context.Context, users []*relation.User) error
Take(ctx context.Context, userID string) (user *relation.User, err error)
Update(ctx context.Context, users []*relation.User) (err error)
UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error)
GetByName(ctx context.Context, userName string, showNumber, pageNumber int32) (users []*relation.User, count int64, err error)
GetByNameAndID(ctx context.Context, content string, showNumber, pageNumber int32) (users []*relation.User, count int64, err error)
Get(ctx context.Context, showNumber, pageNumber int32) (users []*relation.User, count int64, err error)
//userIDs是否存在 只要有一个存在就为true
IsExist(ctx context.Context, userIDs []string) (exist bool, err error)
}
type UserController struct {
+6 -36
View File
@@ -71,44 +71,14 @@ func (b *Black) Take(ctx context.Context, ownerUserID, blockUserID string) (blac
return black, utils.Wrap(b.DB.Where("owner_user_id = ? and block_user_id = ?", ownerUserID, blockUserID).Take(black).Error, "")
}
func (b *Black) FindByOwnerUserID(ctx context.Context, ownerUserID string) (blackList []*Black, err error) {
func (b *Black) FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blacks []*Black, total int64, err error) {
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "blackList", blackList)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ownerUserID", ownerUserID, "blacks", blacks)
}()
return blackList, utils.Wrap(GroupMemberDB.Where("owner_user_id = ?", ownerUserID).Find(&blackList).Error, "")
}
func InsertInToUserBlackList(ctx context.Context, black Black) (err error) {
defer tracelog.SetCtxDebug(ctx, utils.GetSelfFuncName(), err, "black", black)
black.CreateTime = time.Now()
err = BlackDB.Create(black).Error
return err
}
func CheckBlack(ownerUserID, blockUserID string) error {
var black Black
return BlackDB.Where("owner_user_id=? and block_user_id=?", ownerUserID, blockUserID).Find(&black).Error
}
func RemoveBlackList(ownerUserID, blockUserID string) error {
err := BlackDB.Where("owner_user_id=? and block_user_id=?", ownerUserID, blockUserID).Delete(Black{}).Error
return utils.Wrap(err, "RemoveBlackList failed")
}
func GetBlackListByUserID(ownerUserID string) ([]Black, error) {
var blackListUsersInfo []Black
err := BlackDB.Where("owner_user_id=?", ownerUserID).Find(&blackListUsersInfo).Error
err = b.DB.Model(b).Count(&total).Error
if err != nil {
return nil, err
return nil, 0, utils.Wrap(err, "")
}
return blackListUsersInfo, nil
}
func GetBlackIDListByUserID(ownerUserID string) ([]string, error) {
var blackIDList []string
err := b.db.Where("owner_user_id=?", ownerUserID).Pluck("block_user_id", &blackIDList).Error
if err != nil {
return nil, err
}
return blackIDList, nil
err = utils.Wrap(b.DB.Limit(int(showNumber)).Offset(int(pageNumber*showNumber)).Find(&blacks).Error, "")
return
}
+8 -6
View File
@@ -2,7 +2,6 @@ package relation
import (
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db"
pbMsg "Open_IM/pkg/proto/msg"
server_api_params "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
@@ -37,7 +36,11 @@ func (ChatLog) TableName() string {
return "chat_logs"
}
func InsertMessageToChatLog(msg pbMsg.MsgDataToMQ) error {
func NewChatLog(db *gorm.DB) *ChatLog {
return &ChatLog{DB: db}
}
func (c *ChatLog) Create(msg pbMsg.MsgDataToMQ) error {
chatLog := new(ChatLog)
copier.Copy(chatLog, msg.MsgData)
switch msg.MsgData.SessionType {
@@ -61,12 +64,11 @@ func InsertMessageToChatLog(msg pbMsg.MsgDataToMQ) error {
}
chatLog.CreateTime = utils.UnixMillSecondToTime(msg.MsgData.CreateTime)
chatLog.SendTime = utils.UnixMillSecondToTime(msg.MsgData.SendTime)
log.NewDebug("test", "this is ", chatLog)
return db.DB.MysqlDB.DefaultGormDB().Table("chat_logs").Create(chatLog).Error
return c.DB.Create(chatLog).Error
}
func GetChatLog(chatLog *ChatLog, pageNumber, showNumber int32, contentTypeList []int32) (int64, []ChatLog, error) {
mdb := ChatLogDB.Table("chat_logs")
func (c *ChatLog) GetChatLog(chatLog *ChatLog, pageNumber, showNumber int32, contentTypeList []int32) (int64, []ChatLog, error) {
mdb := c.DB.Model(chatLog)
if chatLog.SendTime.Unix() > 0 {
mdb = mdb.Where("send_time > ? and send_time < ?", chatLog.SendTime, chatLog.SendTime.AddDate(0, 0, 1))
}
-50
View File
@@ -1,50 +0,0 @@
package relation
import (
"gorm.io/gorm"
"time"
)
var AppDB *gorm.DB
type AppVersion struct {
Version string `gorm:"column:version;size:64" json:"version"`
Type int `gorm:"column:type;primary_key" json:"type"`
UpdateTime int `gorm:"column:update_time" json:"update_time"`
ForceUpdate bool `gorm:"column:force_update" json:"force_update"`
FileName string `gorm:"column:file_name" json:"file_name"`
YamlName string `gorm:"column:yaml_name" json:"yaml_name"`
UpdateLog string `gorm:"column:update_log" json:"update_log"`
}
func (AppVersion) TableName() string {
return "app_version"
}
func UpdateAppVersion(appType int, version string, forceUpdate bool, fileName, yamlName, updateLog string) error {
updateTime := int(time.Now().Unix())
app := AppVersion{
Version: version,
Type: appType,
UpdateTime: updateTime,
FileName: fileName,
YamlName: yamlName,
ForceUpdate: forceUpdate,
UpdateLog: updateLog,
}
result := AppDB.Model(AppVersion{}).Where("type = ?", appType).Updates(map[string]interface{}{"force_update": forceUpdate,
"version": version, "update_time": int(time.Now().Unix()), "file_name": fileName, "yaml_name": yamlName, "type": appType, "update_log": updateLog})
if result.Error != nil {
return result.Error
}
if result.RowsAffected == 0 {
err := AppDB.Create(&app).Error
return err
}
return nil
}
func GetNewestVersion(appType int) (*AppVersion, error) {
app := AppVersion{}
return &app, AppDB.Model(AppVersion{}).First(&app, appType).Error
}
+1 -1
View File
@@ -26,7 +26,7 @@ type FriendUser struct {
func NewFriendDB(db *gorm.DB) *Friend {
var friend Friend
friend.DB = initModel(db, friend)
friend.DB = db
return &friend
}
+1 -1
View File
@@ -84,7 +84,7 @@ func (u *User) GetByName(ctx context.Context, userName string, showNumber, pageN
func (u *User) GetByNameAndID(ctx context.Context, content string, showNumber, pageNumber int32) (users []*User, count int64, err error) {
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userName", userName, "showNumber", showNumber, "pageNumber", pageNumber, "users", users)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "content", content, "showNumber", showNumber, "pageNumber", pageNumber, "users", users)
}()
db := u.DB.Where(" name like ? or user_id = ? ", fmt.Sprintf("%%%s%%", content), content)
if err := db.Count(&count).Error; err != nil {
+2 -2
View File
@@ -108,8 +108,8 @@ func (db *SuperGroupMgoDB) RemoverUserFromSuperGroup(ctx context.Context, groupI
func (db *SuperGroupMgoDB) GetSuperGroupByUserID(ctx context.Context, userID string) (*UserToSuperGroup, error) {
var user UserToSuperGroup
_ = db.userToSuperGroupCollection.FindOne(ctx, bson.M{"user_id": userID}).Decode(&user)
return &user, nil
err := db.userToSuperGroupCollection.FindOne(ctx, bson.M{"user_id": userID}).Decode(&user)
return &user, utils.Wrap(err, "")
}
func (db *SuperGroupMgoDB) DeleteSuperGroup(ctx context.Context, groupID string) error {
-25
View File
@@ -1,10 +1,6 @@
package middleware
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/token_verify"
"Open_IM/pkg/utils"
"bytes"
"encoding/json"
"github.com/gin-gonic/gin"
@@ -12,27 +8,6 @@ import (
"net/http"
)
func JWTAuth() gin.HandlerFunc {
return func(c *gin.Context) {
ok, userID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), "")
// log.NewInfo("0", utils.GetSelfFuncName(), "userID: ", userID)
c.Set("userID", userID)
if !ok {
log.NewError("", "GetUserIDFromToken false ", c.Request.Header.Get("token"))
c.Abort()
c.JSON(http.StatusOK, gin.H{"errCode": 400, "errMsg": errInfo})
return
} else {
if !utils.IsContain(userID, config.Config.Manager.AppManagerUid) {
c.Abort()
c.JSON(http.StatusOK, gin.H{"errCode": 400, "errMsg": "user is not admin"})
return
}
log.NewInfo("0", utils.GetSelfFuncName(), "failed: ", errInfo)
}
}
}
func CorsHandler() gin.HandlerFunc {
return func(context *gin.Context) {
context.Writer.Header().Set("Access-Control-Allow-Origin", "*")
@@ -1,73 +0,0 @@
package multi_terminal_login
//
//import (
// "Open_IM/internal/push/content_struct"
// "Open_IM/internal/push/logic"
// "Open_IM/pkg/common/config"
// "Open_IM/pkg/common/constant"
// "Open_IM/pkg/common/db"
// pbChat "Open_IM/pkg/proto/msg"
// "Open_IM/pkg/utils"
//)
//
//const DayOfSecond = 24*60*60
//func MultiTerminalLoginChecker(uid, token string, platformID int32) error {
// // 1.check userid and platform class 0 not exists and 1 exists
// exists, err := db.DB.ExistsUserIDAndPlatform(uid, constant.PlatformNameToClass(constant.PlatformIDToName(platformID)))
// if err != nil {
// return err
// }
// //get config multi login policy
// if config.Config.MultiLoginPolicy {
// //OnlyOneTerminalAccess policy need to check all terminal
// if constant.PlatformNameToClass(constant.PlatformIDToName(platformID)) == "PC" {
// exists, err = db.DB.ExistsUserIDAndPlatform(uid, "Mobile")
// if err != nil {
// return err
// }
// } else {
// exists, err = db.DB.ExistsUserIDAndPlatform(uid, "PC")
// if err != nil {
// return err
// }
// }
// if exists == 1 {
// err := db.DB.SetUserIDAndPlatform(uid, constant.PlatformNameToClass(constant.PlatformIDToName(platformID)), token, config.Config.TokenPolicy.AccessExpire*DayOfSecond)
// if err != nil {
// return err
// }
// PushMessageToTheTerminal(uid, platformID)
// return nil
// }
// } else if config.Config.MultiLoginPolicy.MobileAndPCTerminalAccessButOtherTerminalKickEachOther {
// // common terminal need to kick eich other
// if exists == 1 {
// err := db.DB.SetUserIDAndPlatform(uid, constant.PlatformNameToClass(constant.PlatformIDToName(platformID)), token, config.Config.TokenPolicy.AccessExpire*DayOfSecond)
// if err != nil {
// return err
// }
// PushMessageToTheTerminal(uid, platformID)
// return nil
// }
// }
// err = db.DB.SetUserIDAndPlatform(uid, constant.PlatformNameToClass(constant.PlatformIDToName(platformID)), token, config.Config.TokenPolicy.AccessExpire*DayOfSecond)
// if err != nil {
// return err
// }
// PushMessageToTheTerminal(uid, platformID)
// return nil
//}
////
////func PushMessageToTheTerminal(uid string, platform int32) {
////
//// logic.SendMsgByWS(&pbChat.WSToMsgSvrChatMsg{
//// SendID: uid,
//// RecvID: uid,
//// Content: content_struct.NewContentStructString(1, "", "Your account is already logged on other terminal,please confirm"),
//// SendTime: utils.GetCurrentTimestampBySecond(),
//// MsgFrom: constant.SysMsgType,
//// ContentType: constant.KickOnlineTip,
//// PlatformID: platform,
//// })
////}
+3 -233
View File
@@ -3,25 +3,13 @@ package token_verify
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
commonDB "Open_IM/pkg/common/db"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/tracelog"
"Open_IM/pkg/utils"
"context"
"time"
go_redis "github.com/go-redis/redis/v8"
"github.com/golang-jwt/jwt/v4"
"time"
)
//var (
// TokenExpired = errors.New("token is timed out, please log in again")
// TokenInvalid = errors.New("token has been invalidated")
// TokenNotValidYet = errors.New("token not active yet")
// TokenMalformed = errors.New("that's not even a token")
// TokenUnknown = errors.New("couldn't handle this token")
//)
type Claims struct {
UID string
Platform string //login platform
@@ -41,57 +29,6 @@ func BuildClaims(uid, platform string, ttl int64) Claims {
}}
}
func DeleteToken(userID string, platformID int) error {
m, err := commonDB.DB.GetTokenMapByUidPid(userID, constant.PlatformIDToName(platformID))
if err != nil && err != go_redis.Nil {
return utils.Wrap(err, "")
}
var deleteTokenKey []string
for k, v := range m {
_, err = GetClaimFromToken(k)
if err != nil || v != constant.NormalToken {
deleteTokenKey = append(deleteTokenKey, k)
}
}
if len(deleteTokenKey) != 0 {
err = commonDB.DB.DeleteTokenByUidPid(userID, platformID, deleteTokenKey)
return utils.Wrap(err, "")
}
return nil
}
func CreateToken(userID string, platformID int) (string, int64, error) {
claims := BuildClaims(userID, constant.PlatformIDToName(platformID), config.Config.TokenPolicy.AccessExpire)
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
tokenString, err := token.SignedString([]byte(config.Config.TokenPolicy.AccessSecret))
if err != nil {
return "", 0, err
}
//remove Invalid token
m, err := commonDB.DB.GetTokenMapByUidPid(userID, constant.PlatformIDToName(platformID))
if err != nil && err != go_redis.Nil {
return "", 0, err
}
var deleteTokenKey []string
for k, v := range m {
_, err = GetClaimFromToken(k)
if err != nil || v != constant.NormalToken {
deleteTokenKey = append(deleteTokenKey, k)
}
}
if len(deleteTokenKey) != 0 {
err = commonDB.DB.DeleteTokenByUidPid(userID, platformID, deleteTokenKey)
if err != nil {
return "", 0, err
}
}
err = commonDB.DB.AddTokenFlag(userID, platformID, tokenString, constant.NormalToken)
if err != nil {
return "", 0, err
}
return tokenString, claims.ExpiresAt.Time.Unix(), err
}
func secret() jwt.Keyfunc {
return func(token *jwt.Token) (interface{}, error) {
return []byte(config.Config.TokenPolicy.AccessSecret), nil
@@ -122,44 +59,8 @@ func GetClaimFromToken(tokensString string) (*Claims, error) {
}
}
func IsAppManagerAccess(token string, OpUserID string) bool {
claims, err := ParseToken(token, "")
if err != nil {
return false
}
if utils.IsContain(claims.UID, config.Config.Manager.AppManagerUid) && claims.UID == OpUserID {
return true
}
return false
}
func IsManagerUserID(OpUserID string) bool {
if utils.IsContain(OpUserID, config.Config.Manager.AppManagerUid) {
return true
} else {
return false
}
}
func CheckManagerUserID(ctx context.Context, userID string) error {
if utils.IsContain(userID, config.Config.Manager.AppManagerUid) {
return nil
}
return constant.ErrNoPermission.Wrap()
}
func CheckAccess(ctx context.Context, OpUserID string, OwnerUserID string) bool {
if utils.IsContain(OpUserID, config.Config.Manager.AppManagerUid) {
return true
}
if OpUserID == OwnerUserID {
return true
}
return false
}
func CheckAccessV3(ctx context.Context, ownerUserID string) (err error) {
opUserID := utils.OpUserID(ctx)
opUserID := tracelog.GetOpUserID(ctx)
defer func() {
tracelog.SetCtxInfo(ctx, utils.GetFuncName(1), err, "OpUserID", opUserID, "ownerUserID", ownerUserID)
}()
@@ -172,144 +73,13 @@ func CheckAccessV3(ctx context.Context, ownerUserID string) (err error) {
return constant.ErrIdentity.Wrap(utils.GetSelfFuncName())
}
func IsAppManagerUid(ctx context.Context) bool {
return utils.IsContain(utils.OpUserID(ctx), config.Config.Manager.AppManagerUid)
}
func CheckAdmin(ctx context.Context) error {
if utils.IsContain(utils.OpUserID(ctx), config.Config.Manager.AppManagerUid) {
if utils.IsContain(tracelog.GetOpUserID(ctx), config.Config.Manager.AppManagerUid) {
return nil
}
return constant.ErrIdentity.Wrap()
}
func GetUserIDFromToken(token string, operationID string) (bool, string, string) {
claims, err := ParseToken(token, operationID)
if err != nil {
log.Error(operationID, "ParseToken failed, ", err.Error(), token)
return false, "", err.Error()
}
log.Debug(operationID, "token claims.ExpiresAt.Second() ", claims.ExpiresAt.Unix())
return true, claims.UID, ""
}
func ParseUserIDFromToken(token string, operationID string) (string, error) {
claims, err := ParseToken(token, operationID)
if err != nil {
log.Error(operationID, "ParseToken failed, ", err.Error(), token)
return "", err
}
log.Debug(operationID, "token claims.ExpiresAt.Second() ", claims.ExpiresAt.Unix())
return claims.UID, nil
}
func GetUserIDFromTokenExpireTime(token string, operationID string) (bool, string, string, int64) {
claims, err := ParseToken(token, operationID)
if err != nil {
log.Error(operationID, "ParseToken failed, ", err.Error(), token)
return false, "", err.Error(), 0
}
return true, claims.UID, "", claims.ExpiresAt.Unix()
}
func ParseTokenGetUserID(token string, operationID string) (error, string) {
claims, err := ParseToken(token, operationID)
if err != nil {
return utils.Wrap(err, ""), ""
}
return nil, claims.UID
}
func ParseToken(tokensString, operationID string) (claims *Claims, err error) {
claims, err = GetClaimFromToken(tokensString)
if err != nil {
return nil, utils.Wrap(err, "")
}
m, err := commonDB.DB.GetTokenMapByUidPid(claims.UID, claims.Platform)
if err != nil {
log.NewError(operationID, "get token from redis err", err.Error(), claims.UID, claims.Platform)
return nil, utils.Wrap(constant.ErrTokenNotExist, "get token from redis err")
}
if m == nil {
log.NewError(operationID, "get token from redis err, not in redis ", "m is nil ", claims.UID, claims.Platform)
return nil, utils.Wrap(constant.ErrTokenNotExist, "get token from redis err")
}
if v, ok := m[tokensString]; ok {
switch v {
case constant.NormalToken:
log.NewDebug(operationID, "this is normal return ", *claims)
return claims, nil
case constant.KickedToken:
log.Error(operationID, "this token has been kicked by other same terminal ", constant.ErrTokenKicked)
return nil, utils.Wrap(constant.ErrTokenKicked, "this token has been kicked by other same terminal ")
default:
return nil, utils.Wrap(constant.ErrTokenUnknown, "")
}
}
log.NewError(operationID, "redis token map not find ", constant.ErrTokenNotExist, tokensString)
return nil, utils.Wrap(constant.ErrTokenNotExist, "redis token map not find")
}
//func MakeTheTokenInvalid(currentClaims *Claims, platformClass string) (bool, error) {
// storedRedisTokenInterface, err := db.DB.GetPlatformToken(currentClaims.UID, platformClass)
// if err != nil {
// return false, err
// }
// storedRedisPlatformClaims, err := ParseRedisInterfaceToken(storedRedisTokenInterface)
// if err != nil {
// return false, err
// }
// //if issue time less than redis token then make this token invalid
// if currentClaims.IssuedAt.Time.Unix() < storedRedisPlatformClaims.IssuedAt.Time.Unix() {
// return true, constant.TokenInvalid
// }
// return false, nil
//}
func ParseRedisInterfaceToken(redisToken interface{}) (*Claims, error) {
return GetClaimFromToken(string(redisToken.([]uint8)))
}
// Validation token, false means failure, true means successful verification
func VerifyToken(token, uid string) (bool, error) {
claims, err := ParseToken(token, "")
if err != nil {
return false, utils.Wrap(err, "ParseToken failed")
}
if claims.UID != uid {
return false, constant.ErrTokenUnknown
}
log.NewDebug("", claims.UID, claims.Platform)
return true, nil
}
func WsVerifyToken(token, uid string, platformID string, operationID string) (bool, error, string) {
argMsg := "args: token: " + token + " operationID: " + operationID + " userID: " + uid + " platformID: " + constant.PlatformIDToName(utils.StringToInt(platformID))
claims, err := ParseToken(token, operationID)
if err != nil {
//if errors.Is(err, constant.ErrTokenUnknown) {
// errMsg := "ParseToken failed ErrTokenUnknown " + err.Error()
// log.Error(operationID, errMsg)
//}
//e := errors.Unwrap(err)
//if errors.Is(e, constant.ErrTokenUnknown) {
// errMsg := "ParseToken failed ErrTokenUnknown " + e.Error()
// log.Error(operationID, errMsg)
//}
errMsg := "parse token err " + err.Error() + argMsg
return false, utils.Wrap(err, errMsg), errMsg
}
if claims.UID != uid {
errMsg := " uid is not same to token uid " + argMsg + " claims.UID: " + claims.UID
return false, utils.Wrap(constant.ErrTokenDifferentUserID, errMsg), errMsg
}
if claims.Platform != constant.PlatformIDToName(utils.StringToInt(platformID)) {
errMsg := " platform is not same to token platform " + argMsg + " claims platformID: " + claims.Platform
return false, utils.Wrap(constant.ErrTokenDifferentPlatformID, errMsg), errMsg
}
log.NewDebug(operationID, utils.GetSelfFuncName(), " check ok ", claims.UID, uid, claims.Platform)
return true, nil, ""
}
+251 -811
View File
File diff suppressed because it is too large Load Diff
+18 -45
View File
@@ -3,63 +3,36 @@ import "Open-IM-Server/pkg/proto/sdk_ws/ws.proto";
package pbAuth;
option go_package = "Open_IM/pkg/proto/auth;pbAuth";
message CommonResp{
int32 errCode = 1;
string errMsg = 2;
message userTokenReq {
int32 platformID = 1;
string userID = 2;
}
message userTokenResp {
string token = 2;
int64 expireTimeSeconds = 3;
}
message UserRegisterReq {
server_api_params.UserInfo UserInfo = 1;
string OperationID = 2;
message forceLogoutReq {
int32 platformID = 1;
string userID = 2;
}
message UserRegisterResp {
CommonResp CommonResp = 1;
message forceLogoutResp {
}
message UserTokenReq {
int32 Platform = 1;
string FromUserID = 2;
string OpUserID = 3;
string OperationID = 4;
string LoginIp = 5;
}
message UserTokenResp {
CommonResp CommonResp = 1;
string Token = 2;
int64 ExpiredTime = 3;
}
message ForceLogoutReq {
int32 Platform = 1;
string FromUserID = 2;
string OpUserID = 3;
string OperationID = 4;
}
message ForceLogoutResp {
CommonResp CommonResp = 1;
}
message ParseTokenReq{
message parseTokenReq{
string token = 1;
string operationID = 2;
}
message ParseTokenResp{
message parseTokenResp{
string userID = 1;
string platform = 2;
CommonResp commonResp = 3;
uint32 expireTimeSeconds = 4;
int64 expireTimeSeconds = 4;
}
service Auth {
rpc UserRegister(UserRegisterReq) returns(UserRegisterResp);
rpc UserToken(UserTokenReq) returns(UserTokenResp);
rpc ForceLogout(ForceLogoutReq) returns(ForceLogoutResp);
rpc ParseToken(ParseTokenReq)returns(ParseTokenResp);
rpc userToken(userTokenReq) returns(userTokenResp);
rpc forceLogout(forceLogoutReq) returns(forceLogoutResp);
rpc parseToken(parseTokenReq)returns(parseTokenResp);
}
+7 -13
View File
@@ -420,12 +420,6 @@ message OrganizationChangedTips{
//////////////////////friend/////////////////////
//message FriendInfo{
// UserInfo OwnerUser = 1;
// string Remark = 2;
// uint64 CreateTime = 3;
// UserInfo FriendUser = 4;
//}
message FriendApplication{
int64 addTime = 1;
@@ -440,18 +434,18 @@ message FromToUserID{
//FromUserID apply to add ToUserID
message FriendApplicationTips{
FromToUserID fromToUserID = 1;
FromToUserID fromToUserID = 1; //from:发起者; to:接收者
}
//FromUserID accept or reject ToUserID
message FriendApplicationApprovedTips{
FromToUserID fromToUserID = 1;
FromToUserID fromToUserID = 1; //from:同意者;to:请求发起者
string handleMsg = 2;
}
//FromUserID accept or reject ToUserID
message FriendApplicationRejectedTips{
FromToUserID fromToUserID = 1;
FromToUserID fromToUserID = 1; //from:拒绝者;to:请求发起者
string handleMsg = 2;
}
@@ -466,21 +460,21 @@ message FriendAddedTips{
// FromUserID deleted a friend ToUserID
message FriendDeletedTips{
FromToUserID fromToUserID = 1;
FromToUserID fromToUserID = 1; //fromowner tofriend
}
message BlackAddedTips{
FromToUserID fromToUserID = 1;
FromToUserID fromToUserID = 1; //fromowner toblack
}
message BlackDeletedTips{
FromToUserID fromToUserID = 1;
FromToUserID fromToUserID = 1; //fromowner toblack
}
message FriendInfoChangedTips{
FromToUserID fromToUserID = 1;
FromToUserID fromToUserID = 1; //fromchanged tofriend
}
//////////////////////user/////////////////////
message UserInfoUpdatedTips{
+268 -161
View File
@@ -36,7 +36,7 @@ func (m *GetAllUserIDReq) Reset() { *m = GetAllUserIDReq{} }
func (m *GetAllUserIDReq) String() string { return proto.CompactTextString(m) }
func (*GetAllUserIDReq) ProtoMessage() {}
func (*GetAllUserIDReq) Descriptor() ([]byte, []int) {
return fileDescriptor_user_d0f4cea05d456d6d, []int{0}
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{0}
}
func (m *GetAllUserIDReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetAllUserIDReq.Unmarshal(m, b)
@@ -65,7 +65,7 @@ func (m *GetAllUserIDReq) GetPagination() *sdk_ws.RequestPagination {
type GetAllUserIDResp struct {
Total int32 `protobuf:"varint,1,opt,name=total" json:"total,omitempty"`
UserIDList []string `protobuf:"bytes,2,rep,name=UserIDList" json:"UserIDList,omitempty"`
UserIDList []string `protobuf:"bytes,2,rep,name=userIDList" json:"userIDList,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@@ -75,7 +75,7 @@ func (m *GetAllUserIDResp) Reset() { *m = GetAllUserIDResp{} }
func (m *GetAllUserIDResp) String() string { return proto.CompactTextString(m) }
func (*GetAllUserIDResp) ProtoMessage() {}
func (*GetAllUserIDResp) Descriptor() ([]byte, []int) {
return fileDescriptor_user_d0f4cea05d456d6d, []int{1}
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{1}
}
func (m *GetAllUserIDResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetAllUserIDResp.Unmarshal(m, b)
@@ -120,7 +120,7 @@ func (m *AccountCheckReq) Reset() { *m = AccountCheckReq{} }
func (m *AccountCheckReq) String() string { return proto.CompactTextString(m) }
func (*AccountCheckReq) ProtoMessage() {}
func (*AccountCheckReq) Descriptor() ([]byte, []int) {
return fileDescriptor_user_d0f4cea05d456d6d, []int{2}
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{2}
}
func (m *AccountCheckReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_AccountCheckReq.Unmarshal(m, b)
@@ -148,17 +148,17 @@ func (m *AccountCheckReq) GetCheckUserIDs() []string {
}
type AccountCheckResp struct {
Results []*AccountCheckResp_SingleUserStatus `protobuf:"bytes,1,rep,name=results" json:"results,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
Results []*AccountCheckRespSingleUserStatus `protobuf:"bytes,1,rep,name=results" json:"results,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *AccountCheckResp) Reset() { *m = AccountCheckResp{} }
func (m *AccountCheckResp) String() string { return proto.CompactTextString(m) }
func (*AccountCheckResp) ProtoMessage() {}
func (*AccountCheckResp) Descriptor() ([]byte, []int) {
return fileDescriptor_user_d0f4cea05d456d6d, []int{3}
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{3}
}
func (m *AccountCheckResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_AccountCheckResp.Unmarshal(m, b)
@@ -178,14 +178,14 @@ func (m *AccountCheckResp) XXX_DiscardUnknown() {
var xxx_messageInfo_AccountCheckResp proto.InternalMessageInfo
func (m *AccountCheckResp) GetResults() []*AccountCheckResp_SingleUserStatus {
func (m *AccountCheckResp) GetResults() []*AccountCheckRespSingleUserStatus {
if m != nil {
return m.Results
}
return nil
}
type AccountCheckResp_SingleUserStatus struct {
type AccountCheckRespSingleUserStatus struct {
UserID string `protobuf:"bytes,1,opt,name=userID" json:"userID,omitempty"`
AccountStatus string `protobuf:"bytes,2,opt,name=accountStatus" json:"accountStatus,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
@@ -193,38 +193,38 @@ type AccountCheckResp_SingleUserStatus struct {
XXX_sizecache int32 `json:"-"`
}
func (m *AccountCheckResp_SingleUserStatus) Reset() { *m = AccountCheckResp_SingleUserStatus{} }
func (m *AccountCheckResp_SingleUserStatus) String() string { return proto.CompactTextString(m) }
func (*AccountCheckResp_SingleUserStatus) ProtoMessage() {}
func (*AccountCheckResp_SingleUserStatus) Descriptor() ([]byte, []int) {
return fileDescriptor_user_d0f4cea05d456d6d, []int{3, 0}
func (m *AccountCheckRespSingleUserStatus) Reset() { *m = AccountCheckRespSingleUserStatus{} }
func (m *AccountCheckRespSingleUserStatus) String() string { return proto.CompactTextString(m) }
func (*AccountCheckRespSingleUserStatus) ProtoMessage() {}
func (*AccountCheckRespSingleUserStatus) Descriptor() ([]byte, []int) {
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{3, 0}
}
func (m *AccountCheckResp_SingleUserStatus) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_AccountCheckResp_SingleUserStatus.Unmarshal(m, b)
func (m *AccountCheckRespSingleUserStatus) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_AccountCheckRespSingleUserStatus.Unmarshal(m, b)
}
func (m *AccountCheckResp_SingleUserStatus) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_AccountCheckResp_SingleUserStatus.Marshal(b, m, deterministic)
func (m *AccountCheckRespSingleUserStatus) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_AccountCheckRespSingleUserStatus.Marshal(b, m, deterministic)
}
func (dst *AccountCheckResp_SingleUserStatus) XXX_Merge(src proto.Message) {
xxx_messageInfo_AccountCheckResp_SingleUserStatus.Merge(dst, src)
func (dst *AccountCheckRespSingleUserStatus) XXX_Merge(src proto.Message) {
xxx_messageInfo_AccountCheckRespSingleUserStatus.Merge(dst, src)
}
func (m *AccountCheckResp_SingleUserStatus) XXX_Size() int {
return xxx_messageInfo_AccountCheckResp_SingleUserStatus.Size(m)
func (m *AccountCheckRespSingleUserStatus) XXX_Size() int {
return xxx_messageInfo_AccountCheckRespSingleUserStatus.Size(m)
}
func (m *AccountCheckResp_SingleUserStatus) XXX_DiscardUnknown() {
xxx_messageInfo_AccountCheckResp_SingleUserStatus.DiscardUnknown(m)
func (m *AccountCheckRespSingleUserStatus) XXX_DiscardUnknown() {
xxx_messageInfo_AccountCheckRespSingleUserStatus.DiscardUnknown(m)
}
var xxx_messageInfo_AccountCheckResp_SingleUserStatus proto.InternalMessageInfo
var xxx_messageInfo_AccountCheckRespSingleUserStatus proto.InternalMessageInfo
func (m *AccountCheckResp_SingleUserStatus) GetUserID() string {
func (m *AccountCheckRespSingleUserStatus) GetUserID() string {
if m != nil {
return m.UserID
}
return ""
}
func (m *AccountCheckResp_SingleUserStatus) GetAccountStatus() string {
func (m *AccountCheckRespSingleUserStatus) GetAccountStatus() string {
if m != nil {
return m.AccountStatus
}
@@ -242,7 +242,7 @@ func (m *GetUsersInfoReq) Reset() { *m = GetUsersInfoReq{} }
func (m *GetUsersInfoReq) String() string { return proto.CompactTextString(m) }
func (*GetUsersInfoReq) ProtoMessage() {}
func (*GetUsersInfoReq) Descriptor() ([]byte, []int) {
return fileDescriptor_user_d0f4cea05d456d6d, []int{4}
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{4}
}
func (m *GetUsersInfoReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetUsersInfoReq.Unmarshal(m, b)
@@ -280,7 +280,7 @@ func (m *GetUsersInfoResp) Reset() { *m = GetUsersInfoResp{} }
func (m *GetUsersInfoResp) String() string { return proto.CompactTextString(m) }
func (*GetUsersInfoResp) ProtoMessage() {}
func (*GetUsersInfoResp) Descriptor() ([]byte, []int) {
return fileDescriptor_user_d0f4cea05d456d6d, []int{5}
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{5}
}
func (m *GetUsersInfoResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetUsersInfoResp.Unmarshal(m, b)
@@ -318,7 +318,7 @@ func (m *UpdateUserInfoReq) Reset() { *m = UpdateUserInfoReq{} }
func (m *UpdateUserInfoReq) String() string { return proto.CompactTextString(m) }
func (*UpdateUserInfoReq) ProtoMessage() {}
func (*UpdateUserInfoReq) Descriptor() ([]byte, []int) {
return fileDescriptor_user_d0f4cea05d456d6d, []int{6}
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{6}
}
func (m *UpdateUserInfoReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_UpdateUserInfoReq.Unmarshal(m, b)
@@ -355,7 +355,7 @@ func (m *UpdateUserInfoResp) Reset() { *m = UpdateUserInfoResp{} }
func (m *UpdateUserInfoResp) String() string { return proto.CompactTextString(m) }
func (*UpdateUserInfoResp) ProtoMessage() {}
func (*UpdateUserInfoResp) Descriptor() ([]byte, []int) {
return fileDescriptor_user_d0f4cea05d456d6d, []int{7}
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{7}
}
func (m *UpdateUserInfoResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_UpdateUserInfoResp.Unmarshal(m, b)
@@ -387,7 +387,7 @@ func (m *SetGlobalRecvMessageOptReq) Reset() { *m = SetGlobalRecvMessage
func (m *SetGlobalRecvMessageOptReq) String() string { return proto.CompactTextString(m) }
func (*SetGlobalRecvMessageOptReq) ProtoMessage() {}
func (*SetGlobalRecvMessageOptReq) Descriptor() ([]byte, []int) {
return fileDescriptor_user_d0f4cea05d456d6d, []int{8}
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{8}
}
func (m *SetGlobalRecvMessageOptReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SetGlobalRecvMessageOptReq.Unmarshal(m, b)
@@ -431,7 +431,7 @@ func (m *SetGlobalRecvMessageOptResp) Reset() { *m = SetGlobalRecvMessag
func (m *SetGlobalRecvMessageOptResp) String() string { return proto.CompactTextString(m) }
func (*SetGlobalRecvMessageOptResp) ProtoMessage() {}
func (*SetGlobalRecvMessageOptResp) Descriptor() ([]byte, []int) {
return fileDescriptor_user_d0f4cea05d456d6d, []int{9}
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{9}
}
func (m *SetGlobalRecvMessageOptResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SetGlobalRecvMessageOptResp.Unmarshal(m, b)
@@ -452,9 +452,9 @@ func (m *SetGlobalRecvMessageOptResp) XXX_DiscardUnknown() {
var xxx_messageInfo_SetGlobalRecvMessageOptResp proto.InternalMessageInfo
type SetConversationReq struct {
Conversation *conversation.Conversation `protobuf:"bytes,1,opt,name=Conversation" json:"Conversation,omitempty"`
Conversation *conversation.Conversation `protobuf:"bytes,1,opt,name=conversation" json:"conversation,omitempty"`
NotificationType int32 `protobuf:"varint,2,opt,name=notificationType" json:"notificationType,omitempty"`
OperationID string `protobuf:"bytes,3,opt,name=OperationID" json:"OperationID,omitempty"`
OperationID string `protobuf:"bytes,3,opt,name=operationID" json:"operationID,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@@ -464,7 +464,7 @@ func (m *SetConversationReq) Reset() { *m = SetConversationReq{} }
func (m *SetConversationReq) String() string { return proto.CompactTextString(m) }
func (*SetConversationReq) ProtoMessage() {}
func (*SetConversationReq) Descriptor() ([]byte, []int) {
return fileDescriptor_user_d0f4cea05d456d6d, []int{10}
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{10}
}
func (m *SetConversationReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SetConversationReq.Unmarshal(m, b)
@@ -515,7 +515,7 @@ func (m *SetConversationResp) Reset() { *m = SetConversationResp{} }
func (m *SetConversationResp) String() string { return proto.CompactTextString(m) }
func (*SetConversationResp) ProtoMessage() {}
func (*SetConversationResp) Descriptor() ([]byte, []int) {
return fileDescriptor_user_d0f4cea05d456d6d, []int{11}
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{11}
}
func (m *SetConversationResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SetConversationResp.Unmarshal(m, b)
@@ -536,11 +536,11 @@ func (m *SetConversationResp) XXX_DiscardUnknown() {
var xxx_messageInfo_SetConversationResp proto.InternalMessageInfo
type SetRecvMsgOptReq struct {
OwnerUserID string `protobuf:"bytes,1,opt,name=OwnerUserID" json:"OwnerUserID,omitempty"`
ConversationID string `protobuf:"bytes,2,opt,name=ConversationID" json:"ConversationID,omitempty"`
RecvMsgOpt int32 `protobuf:"varint,3,opt,name=RecvMsgOpt" json:"RecvMsgOpt,omitempty"`
OwnerUserID string `protobuf:"bytes,1,opt,name=ownerUserID" json:"ownerUserID,omitempty"`
ConversationID string `protobuf:"bytes,2,opt,name=conversationID" json:"conversationID,omitempty"`
RecvMsgOpt int32 `protobuf:"varint,3,opt,name=recvMsgOpt" json:"recvMsgOpt,omitempty"`
NotificationType int32 `protobuf:"varint,4,opt,name=notificationType" json:"notificationType,omitempty"`
OperationID string `protobuf:"bytes,5,opt,name=OperationID" json:"OperationID,omitempty"`
OperationID string `protobuf:"bytes,5,opt,name=operationID" json:"operationID,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@@ -550,7 +550,7 @@ func (m *SetRecvMsgOptReq) Reset() { *m = SetRecvMsgOptReq{} }
func (m *SetRecvMsgOptReq) String() string { return proto.CompactTextString(m) }
func (*SetRecvMsgOptReq) ProtoMessage() {}
func (*SetRecvMsgOptReq) Descriptor() ([]byte, []int) {
return fileDescriptor_user_d0f4cea05d456d6d, []int{12}
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{12}
}
func (m *SetRecvMsgOptReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SetRecvMsgOptReq.Unmarshal(m, b)
@@ -615,7 +615,7 @@ func (m *SetRecvMsgOptResp) Reset() { *m = SetRecvMsgOptResp{} }
func (m *SetRecvMsgOptResp) String() string { return proto.CompactTextString(m) }
func (*SetRecvMsgOptResp) ProtoMessage() {}
func (*SetRecvMsgOptResp) Descriptor() ([]byte, []int) {
return fileDescriptor_user_d0f4cea05d456d6d, []int{13}
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{13}
}
func (m *SetRecvMsgOptResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SetRecvMsgOptResp.Unmarshal(m, b)
@@ -636,9 +636,9 @@ func (m *SetRecvMsgOptResp) XXX_DiscardUnknown() {
var xxx_messageInfo_SetRecvMsgOptResp proto.InternalMessageInfo
type GetConversationReq struct {
ConversationID string `protobuf:"bytes,1,opt,name=ConversationID" json:"ConversationID,omitempty"`
OwnerUserID string `protobuf:"bytes,2,opt,name=OwnerUserID" json:"OwnerUserID,omitempty"`
OperationID string `protobuf:"bytes,3,opt,name=OperationID" json:"OperationID,omitempty"`
ConversationID string `protobuf:"bytes,1,opt,name=conversationID" json:"conversationID,omitempty"`
OwnerUserID string `protobuf:"bytes,2,opt,name=ownerUserID" json:"ownerUserID,omitempty"`
OperationID string `protobuf:"bytes,3,opt,name=operationID" json:"operationID,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@@ -648,7 +648,7 @@ func (m *GetConversationReq) Reset() { *m = GetConversationReq{} }
func (m *GetConversationReq) String() string { return proto.CompactTextString(m) }
func (*GetConversationReq) ProtoMessage() {}
func (*GetConversationReq) Descriptor() ([]byte, []int) {
return fileDescriptor_user_d0f4cea05d456d6d, []int{14}
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{14}
}
func (m *GetConversationReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetConversationReq.Unmarshal(m, b)
@@ -690,7 +690,7 @@ func (m *GetConversationReq) GetOperationID() string {
}
type GetConversationResp struct {
Conversation *conversation.Conversation `protobuf:"bytes,2,opt,name=Conversation" json:"Conversation,omitempty"`
Conversation *conversation.Conversation `protobuf:"bytes,2,opt,name=conversation" json:"conversation,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@@ -700,7 +700,7 @@ func (m *GetConversationResp) Reset() { *m = GetConversationResp{} }
func (m *GetConversationResp) String() string { return proto.CompactTextString(m) }
func (*GetConversationResp) ProtoMessage() {}
func (*GetConversationResp) Descriptor() ([]byte, []int) {
return fileDescriptor_user_d0f4cea05d456d6d, []int{15}
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{15}
}
func (m *GetConversationResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetConversationResp.Unmarshal(m, b)
@@ -728,9 +728,9 @@ func (m *GetConversationResp) GetConversation() *conversation.Conversation {
}
type GetConversationsReq struct {
OwnerUserID string `protobuf:"bytes,1,opt,name=OwnerUserID" json:"OwnerUserID,omitempty"`
ConversationIDs []string `protobuf:"bytes,2,rep,name=ConversationIDs" json:"ConversationIDs,omitempty"`
OperationID string `protobuf:"bytes,3,opt,name=OperationID" json:"OperationID,omitempty"`
OwnerUserID string `protobuf:"bytes,1,opt,name=ownerUserID" json:"ownerUserID,omitempty"`
ConversationIDs []string `protobuf:"bytes,2,rep,name=conversationIDs" json:"conversationIDs,omitempty"`
OperationID string `protobuf:"bytes,3,opt,name=operationID" json:"operationID,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@@ -740,7 +740,7 @@ func (m *GetConversationsReq) Reset() { *m = GetConversationsReq{} }
func (m *GetConversationsReq) String() string { return proto.CompactTextString(m) }
func (*GetConversationsReq) ProtoMessage() {}
func (*GetConversationsReq) Descriptor() ([]byte, []int) {
return fileDescriptor_user_d0f4cea05d456d6d, []int{16}
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{16}
}
func (m *GetConversationsReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetConversationsReq.Unmarshal(m, b)
@@ -782,7 +782,7 @@ func (m *GetConversationsReq) GetOperationID() string {
}
type GetConversationsResp struct {
Conversations []*conversation.Conversation `protobuf:"bytes,2,rep,name=Conversations" json:"Conversations,omitempty"`
Conversations []*conversation.Conversation `protobuf:"bytes,2,rep,name=conversations" json:"conversations,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@@ -792,7 +792,7 @@ func (m *GetConversationsResp) Reset() { *m = GetConversationsResp{} }
func (m *GetConversationsResp) String() string { return proto.CompactTextString(m) }
func (*GetConversationsResp) ProtoMessage() {}
func (*GetConversationsResp) Descriptor() ([]byte, []int) {
return fileDescriptor_user_d0f4cea05d456d6d, []int{17}
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{17}
}
func (m *GetConversationsResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetConversationsResp.Unmarshal(m, b)
@@ -820,8 +820,8 @@ func (m *GetConversationsResp) GetConversations() []*conversation.Conversation {
}
type GetAllConversationsReq struct {
OwnerUserID string `protobuf:"bytes,1,opt,name=OwnerUserID" json:"OwnerUserID,omitempty"`
OperationID string `protobuf:"bytes,2,opt,name=OperationID" json:"OperationID,omitempty"`
OwnerUserID string `protobuf:"bytes,1,opt,name=ownerUserID" json:"ownerUserID,omitempty"`
OperationID string `protobuf:"bytes,2,opt,name=operationID" json:"operationID,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@@ -831,7 +831,7 @@ func (m *GetAllConversationsReq) Reset() { *m = GetAllConversationsReq{}
func (m *GetAllConversationsReq) String() string { return proto.CompactTextString(m) }
func (*GetAllConversationsReq) ProtoMessage() {}
func (*GetAllConversationsReq) Descriptor() ([]byte, []int) {
return fileDescriptor_user_d0f4cea05d456d6d, []int{18}
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{18}
}
func (m *GetAllConversationsReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetAllConversationsReq.Unmarshal(m, b)
@@ -866,7 +866,7 @@ func (m *GetAllConversationsReq) GetOperationID() string {
}
type GetAllConversationsResp struct {
Conversations []*conversation.Conversation `protobuf:"bytes,2,rep,name=Conversations" json:"Conversations,omitempty"`
Conversations []*conversation.Conversation `protobuf:"bytes,2,rep,name=conversations" json:"conversations,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@@ -876,7 +876,7 @@ func (m *GetAllConversationsResp) Reset() { *m = GetAllConversationsResp
func (m *GetAllConversationsResp) String() string { return proto.CompactTextString(m) }
func (*GetAllConversationsResp) ProtoMessage() {}
func (*GetAllConversationsResp) Descriptor() ([]byte, []int) {
return fileDescriptor_user_d0f4cea05d456d6d, []int{19}
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{19}
}
func (m *GetAllConversationsResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetAllConversationsResp.Unmarshal(m, b)
@@ -904,7 +904,7 @@ func (m *GetAllConversationsResp) GetConversations() []*conversation.Conversatio
}
type BatchSetConversationsReq struct {
Conversations []*conversation.Conversation `protobuf:"bytes,1,rep,name=Conversations" json:"Conversations,omitempty"`
Conversations []*conversation.Conversation `protobuf:"bytes,1,rep,name=conversations" json:"conversations,omitempty"`
OwnerUserID string `protobuf:"bytes,2,opt,name=OwnerUserID" json:"OwnerUserID,omitempty"`
NotificationType int32 `protobuf:"varint,3,opt,name=notificationType" json:"notificationType,omitempty"`
OperationID string `protobuf:"bytes,4,opt,name=OperationID" json:"OperationID,omitempty"`
@@ -917,7 +917,7 @@ func (m *BatchSetConversationsReq) Reset() { *m = BatchSetConversationsR
func (m *BatchSetConversationsReq) String() string { return proto.CompactTextString(m) }
func (*BatchSetConversationsReq) ProtoMessage() {}
func (*BatchSetConversationsReq) Descriptor() ([]byte, []int) {
return fileDescriptor_user_d0f4cea05d456d6d, []int{20}
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{20}
}
func (m *BatchSetConversationsReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_BatchSetConversationsReq.Unmarshal(m, b)
@@ -977,7 +977,7 @@ func (m *BatchSetConversationsResp) Reset() { *m = BatchSetConversations
func (m *BatchSetConversationsResp) String() string { return proto.CompactTextString(m) }
func (*BatchSetConversationsResp) ProtoMessage() {}
func (*BatchSetConversationsResp) Descriptor() ([]byte, []int) {
return fileDescriptor_user_d0f4cea05d456d6d, []int{21}
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{21}
}
func (m *BatchSetConversationsResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_BatchSetConversationsResp.Unmarshal(m, b)
@@ -1025,7 +1025,7 @@ func (m *GetUsersReq) Reset() { *m = GetUsersReq{} }
func (m *GetUsersReq) String() string { return proto.CompactTextString(m) }
func (*GetUsersReq) ProtoMessage() {}
func (*GetUsersReq) Descriptor() ([]byte, []int) {
return fileDescriptor_user_d0f4cea05d456d6d, []int{22}
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{22}
}
func (m *GetUsersReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetUsersReq.Unmarshal(m, b)
@@ -1085,7 +1085,7 @@ func (m *GetUsersResp) Reset() { *m = GetUsersResp{} }
func (m *GetUsersResp) String() string { return proto.CompactTextString(m) }
func (*GetUsersResp) ProtoMessage() {}
func (*GetUsersResp) Descriptor() ([]byte, []int) {
return fileDescriptor_user_d0f4cea05d456d6d, []int{23}
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{23}
}
func (m *GetUsersResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_GetUsersResp.Unmarshal(m, b)
@@ -1119,32 +1119,102 @@ func (m *GetUsersResp) GetUsers() []*sdk_ws.UserInfo {
return nil
}
type UserRegisterReq struct {
Users []*sdk_ws.UserInfo `protobuf:"bytes,1,rep,name=users" json:"users,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *UserRegisterReq) Reset() { *m = UserRegisterReq{} }
func (m *UserRegisterReq) String() string { return proto.CompactTextString(m) }
func (*UserRegisterReq) ProtoMessage() {}
func (*UserRegisterReq) Descriptor() ([]byte, []int) {
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{24}
}
func (m *UserRegisterReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_UserRegisterReq.Unmarshal(m, b)
}
func (m *UserRegisterReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_UserRegisterReq.Marshal(b, m, deterministic)
}
func (dst *UserRegisterReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_UserRegisterReq.Merge(dst, src)
}
func (m *UserRegisterReq) XXX_Size() int {
return xxx_messageInfo_UserRegisterReq.Size(m)
}
func (m *UserRegisterReq) XXX_DiscardUnknown() {
xxx_messageInfo_UserRegisterReq.DiscardUnknown(m)
}
var xxx_messageInfo_UserRegisterReq proto.InternalMessageInfo
func (m *UserRegisterReq) GetUsers() []*sdk_ws.UserInfo {
if m != nil {
return m.Users
}
return nil
}
type UserRegisterResp struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *UserRegisterResp) Reset() { *m = UserRegisterResp{} }
func (m *UserRegisterResp) String() string { return proto.CompactTextString(m) }
func (*UserRegisterResp) ProtoMessage() {}
func (*UserRegisterResp) Descriptor() ([]byte, []int) {
return fileDescriptor_user_ca0d4cfbb41aa43a, []int{25}
}
func (m *UserRegisterResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_UserRegisterResp.Unmarshal(m, b)
}
func (m *UserRegisterResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_UserRegisterResp.Marshal(b, m, deterministic)
}
func (dst *UserRegisterResp) XXX_Merge(src proto.Message) {
xxx_messageInfo_UserRegisterResp.Merge(dst, src)
}
func (m *UserRegisterResp) XXX_Size() int {
return xxx_messageInfo_UserRegisterResp.Size(m)
}
func (m *UserRegisterResp) XXX_DiscardUnknown() {
xxx_messageInfo_UserRegisterResp.DiscardUnknown(m)
}
var xxx_messageInfo_UserRegisterResp proto.InternalMessageInfo
func init() {
proto.RegisterType((*GetAllUserIDReq)(nil), "user.GetAllUserIDReq")
proto.RegisterType((*GetAllUserIDResp)(nil), "user.GetAllUserIDResp")
proto.RegisterType((*AccountCheckReq)(nil), "user.AccountCheckReq")
proto.RegisterType((*AccountCheckResp)(nil), "user.AccountCheckResp")
proto.RegisterType((*AccountCheckResp_SingleUserStatus)(nil), "user.AccountCheckResp.SingleUserStatus")
proto.RegisterType((*GetUsersInfoReq)(nil), "user.GetUsersInfoReq")
proto.RegisterType((*GetUsersInfoResp)(nil), "user.GetUsersInfoResp")
proto.RegisterType((*UpdateUserInfoReq)(nil), "user.UpdateUserInfoReq")
proto.RegisterType((*UpdateUserInfoResp)(nil), "user.UpdateUserInfoResp")
proto.RegisterType((*SetGlobalRecvMessageOptReq)(nil), "user.SetGlobalRecvMessageOptReq")
proto.RegisterType((*SetGlobalRecvMessageOptResp)(nil), "user.SetGlobalRecvMessageOptResp")
proto.RegisterType((*SetConversationReq)(nil), "user.SetConversationReq")
proto.RegisterType((*SetConversationResp)(nil), "user.SetConversationResp")
proto.RegisterType((*SetRecvMsgOptReq)(nil), "user.SetRecvMsgOptReq")
proto.RegisterType((*SetRecvMsgOptResp)(nil), "user.SetRecvMsgOptResp")
proto.RegisterType((*GetConversationReq)(nil), "user.GetConversationReq")
proto.RegisterType((*GetConversationResp)(nil), "user.GetConversationResp")
proto.RegisterType((*GetConversationsReq)(nil), "user.GetConversationsReq")
proto.RegisterType((*GetConversationsResp)(nil), "user.GetConversationsResp")
proto.RegisterType((*GetAllConversationsReq)(nil), "user.GetAllConversationsReq")
proto.RegisterType((*GetAllConversationsResp)(nil), "user.GetAllConversationsResp")
proto.RegisterType((*BatchSetConversationsReq)(nil), "user.BatchSetConversationsReq")
proto.RegisterType((*BatchSetConversationsResp)(nil), "user.BatchSetConversationsResp")
proto.RegisterType((*GetUsersReq)(nil), "user.GetUsersReq")
proto.RegisterType((*GetUsersResp)(nil), "user.GetUsersResp")
proto.RegisterType((*GetAllUserIDReq)(nil), "user.getAllUserIDReq")
proto.RegisterType((*GetAllUserIDResp)(nil), "user.getAllUserIDResp")
proto.RegisterType((*AccountCheckReq)(nil), "user.accountCheckReq")
proto.RegisterType((*AccountCheckResp)(nil), "user.accountCheckResp")
proto.RegisterType((*AccountCheckRespSingleUserStatus)(nil), "user.accountCheckResp.singleUserStatus")
proto.RegisterType((*GetUsersInfoReq)(nil), "user.getUsersInfoReq")
proto.RegisterType((*GetUsersInfoResp)(nil), "user.getUsersInfoResp")
proto.RegisterType((*UpdateUserInfoReq)(nil), "user.updateUserInfoReq")
proto.RegisterType((*UpdateUserInfoResp)(nil), "user.updateUserInfoResp")
proto.RegisterType((*SetGlobalRecvMessageOptReq)(nil), "user.setGlobalRecvMessageOptReq")
proto.RegisterType((*SetGlobalRecvMessageOptResp)(nil), "user.setGlobalRecvMessageOptResp")
proto.RegisterType((*SetConversationReq)(nil), "user.setConversationReq")
proto.RegisterType((*SetConversationResp)(nil), "user.setConversationResp")
proto.RegisterType((*SetRecvMsgOptReq)(nil), "user.setRecvMsgOptReq")
proto.RegisterType((*SetRecvMsgOptResp)(nil), "user.setRecvMsgOptResp")
proto.RegisterType((*GetConversationReq)(nil), "user.getConversationReq")
proto.RegisterType((*GetConversationResp)(nil), "user.getConversationResp")
proto.RegisterType((*GetConversationsReq)(nil), "user.getConversationsReq")
proto.RegisterType((*GetConversationsResp)(nil), "user.getConversationsResp")
proto.RegisterType((*GetAllConversationsReq)(nil), "user.getAllConversationsReq")
proto.RegisterType((*GetAllConversationsResp)(nil), "user.getAllConversationsResp")
proto.RegisterType((*BatchSetConversationsReq)(nil), "user.batchSetConversationsReq")
proto.RegisterType((*BatchSetConversationsResp)(nil), "user.batchSetConversationsResp")
proto.RegisterType((*GetUsersReq)(nil), "user.getUsersReq")
proto.RegisterType((*GetUsersResp)(nil), "user.getUsersResp")
proto.RegisterType((*UserRegisterReq)(nil), "user.userRegisterReq")
proto.RegisterType((*UserRegisterResp)(nil), "user.userRegisterResp")
}
// Reference imports to suppress errors if they are not otherwise used.
@@ -1168,6 +1238,8 @@ type UserClient interface {
AccountCheck(ctx context.Context, in *AccountCheckReq, opts ...grpc.CallOption) (*AccountCheckResp, error)
// 翻页(或指定userID,昵称)拉取用户信息 全字段
GetUsers(ctx context.Context, in *GetUsersReq, opts ...grpc.CallOption) (*GetUsersResp, error)
// 用户注册
UserRegister(ctx context.Context, in *UserRegisterReq, opts ...grpc.CallOption) (*UserRegisterResp, error)
}
type userClient struct {
@@ -1180,7 +1252,7 @@ func NewUserClient(cc *grpc.ClientConn) UserClient {
func (c *userClient) GetUsersInfo(ctx context.Context, in *GetUsersInfoReq, opts ...grpc.CallOption) (*GetUsersInfoResp, error) {
out := new(GetUsersInfoResp)
err := grpc.Invoke(ctx, "/user.user/GetUsersInfo", in, out, c.cc, opts...)
err := grpc.Invoke(ctx, "/user.user/getUsersInfo", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
@@ -1189,7 +1261,7 @@ func (c *userClient) GetUsersInfo(ctx context.Context, in *GetUsersInfoReq, opts
func (c *userClient) UpdateUserInfo(ctx context.Context, in *UpdateUserInfoReq, opts ...grpc.CallOption) (*UpdateUserInfoResp, error) {
out := new(UpdateUserInfoResp)
err := grpc.Invoke(ctx, "/user.user/UpdateUserInfo", in, out, c.cc, opts...)
err := grpc.Invoke(ctx, "/user.user/updateUserInfo", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
@@ -1198,7 +1270,7 @@ func (c *userClient) UpdateUserInfo(ctx context.Context, in *UpdateUserInfoReq,
func (c *userClient) SetGlobalRecvMessageOpt(ctx context.Context, in *SetGlobalRecvMessageOptReq, opts ...grpc.CallOption) (*SetGlobalRecvMessageOptResp, error) {
out := new(SetGlobalRecvMessageOptResp)
err := grpc.Invoke(ctx, "/user.user/SetGlobalRecvMessageOpt", in, out, c.cc, opts...)
err := grpc.Invoke(ctx, "/user.user/setGlobalRecvMessageOpt", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
@@ -1207,7 +1279,7 @@ func (c *userClient) SetGlobalRecvMessageOpt(ctx context.Context, in *SetGlobalR
func (c *userClient) AccountCheck(ctx context.Context, in *AccountCheckReq, opts ...grpc.CallOption) (*AccountCheckResp, error) {
out := new(AccountCheckResp)
err := grpc.Invoke(ctx, "/user.user/AccountCheck", in, out, c.cc, opts...)
err := grpc.Invoke(ctx, "/user.user/accountCheck", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
@@ -1216,7 +1288,16 @@ func (c *userClient) AccountCheck(ctx context.Context, in *AccountCheckReq, opts
func (c *userClient) GetUsers(ctx context.Context, in *GetUsersReq, opts ...grpc.CallOption) (*GetUsersResp, error) {
out := new(GetUsersResp)
err := grpc.Invoke(ctx, "/user.user/GetUsers", in, out, c.cc, opts...)
err := grpc.Invoke(ctx, "/user.user/getUsers", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *userClient) UserRegister(ctx context.Context, in *UserRegisterReq, opts ...grpc.CallOption) (*UserRegisterResp, error) {
out := new(UserRegisterResp)
err := grpc.Invoke(ctx, "/user.user/userRegister", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
@@ -1236,6 +1317,8 @@ type UserServer interface {
AccountCheck(context.Context, *AccountCheckReq) (*AccountCheckResp, error)
// 翻页(或指定userID,昵称)拉取用户信息 全字段
GetUsers(context.Context, *GetUsersReq) (*GetUsersResp, error)
// 用户注册
UserRegister(context.Context, *UserRegisterReq) (*UserRegisterResp, error)
}
func RegisterUserServer(s *grpc.Server, srv UserServer) {
@@ -1332,93 +1415,117 @@ func _User_GetUsers_Handler(srv interface{}, ctx context.Context, dec func(inter
return interceptor(ctx, in, info, handler)
}
func _User_UserRegister_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UserRegisterReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServer).UserRegister(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/user.user/UserRegister",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServer).UserRegister(ctx, req.(*UserRegisterReq))
}
return interceptor(ctx, in, info, handler)
}
var _User_serviceDesc = grpc.ServiceDesc{
ServiceName: "user.user",
HandlerType: (*UserServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "GetUsersInfo",
MethodName: "getUsersInfo",
Handler: _User_GetUsersInfo_Handler,
},
{
MethodName: "UpdateUserInfo",
MethodName: "updateUserInfo",
Handler: _User_UpdateUserInfo_Handler,
},
{
MethodName: "SetGlobalRecvMessageOpt",
MethodName: "setGlobalRecvMessageOpt",
Handler: _User_SetGlobalRecvMessageOpt_Handler,
},
{
MethodName: "AccountCheck",
MethodName: "accountCheck",
Handler: _User_AccountCheck_Handler,
},
{
MethodName: "GetUsers",
MethodName: "getUsers",
Handler: _User_GetUsers_Handler,
},
{
MethodName: "userRegister",
Handler: _User_UserRegister_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "user/user.proto",
}
func init() { proto.RegisterFile("user/user.proto", fileDescriptor_user_d0f4cea05d456d6d) }
func init() { proto.RegisterFile("user/user.proto", fileDescriptor_user_ca0d4cfbb41aa43a) }
var fileDescriptor_user_d0f4cea05d456d6d = []byte{
// 887 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xe1, 0x6e, 0xdc, 0x44,
0x10, 0x96, 0x2f, 0xb9, 0xa6, 0x99, 0xa4, 0xcd, 0x65, 0x93, 0x26, 0xc6, 0x51, 0xd1, 0xb1, 0xaa,
0xe0, 0x04, 0xea, 0x9d, 0x1a, 0x84, 0x00, 0x21, 0x10, 0x69, 0x4e, 0x1c, 0x27, 0xf5, 0xb8, 0xca,
0xe6, 0x54, 0x04, 0x88, 0xc3, 0x75, 0xb6, 0x57, 0x2b, 0xae, 0xbd, 0xf1, 0xac, 0x13, 0xf1, 0x0f,
0x89, 0x27, 0x81, 0x3f, 0xbc, 0x0b, 0xe2, 0x11, 0x78, 0x18, 0xb4, 0x6b, 0xfb, 0xce, 0xf6, 0xfa,
0xd2, 0x6b, 0xd4, 0x3f, 0x96, 0xe7, 0xdb, 0x99, 0x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c, 0xce, 0x3e, 0x39, 0xc7, 0xca,
0xc0, 0x95, 0x73, 0xd4, 0xe6, 0xa9, 0x47, 0x70, 0x3b, 0xe7, 0x4d, 0x76, 0xcb, 0x79, 0x90, 0x66,
0xa4, 0x0a, 0x21, 0x7f, 0x7c, 0xff, 0xc7, 0x23, 0x39, 0xad, 0x4e, 0x87, 0xa3, 0xc2, 0x98, 0x2a,
0xd5, 0xbe, 0x90, 0x9f, 0xe7, 0xb7, 0x14, 0xf0, 0xf1, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x37,
0x21, 0xab, 0xd2, 0x14, 0x0b, 0x00, 0x00,
var fileDescriptor_user_ca0d4cfbb41aa43a = []byte{
// 926 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x51, 0x6f, 0xdc, 0x44,
0x10, 0x96, 0xef, 0x72, 0x4d, 0x33, 0x49, 0x9b, 0xcb, 0x26, 0x4d, 0x8c, 0xa3, 0xa2, 0xb0, 0xaa,
0x20, 0x02, 0xf5, 0x4e, 0x0d, 0x42, 0x80, 0x10, 0x88, 0x92, 0x13, 0x70, 0x52, 0x8f, 0xab, 0x1c,
0xa2, 0x22, 0x40, 0x04, 0xc7, 0xd9, 0xba, 0x56, 0xae, 0xf6, 0xc6, 0xb3, 0x4e, 0xc4, 0x1b, 0x12,
0x3f, 0x83, 0x27, 0x78, 0xe1, 0xbf, 0x20, 0x7e, 0x14, 0xda, 0x5d, 0x3b, 0xb7, 0xf6, 0xda, 0x69,
0x1a, 0xf5, 0x25, 0xb9, 0x99, 0x9d, 0xf9, 0x76, 0xbe, 0x99, 0x59, 0xcf, 0xc0, 0x6a, 0x8e, 0x2c,
0x1b, 0xca, 0x3f, 0x03, 0x9e, 0xa5, 0x22, 0x25, 0x0b, 0xf2, 0xb7, 0xb7, 0x3b, 0xe5, 0x2c, 0x79,
0x38, 0x9e, 0x3c, 0x3c,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xaa, 0x92, 0x63, 0x6d, 0x95, 0x2b, 0x39, 0x5a, 0x9b,
0xda, 0x23, 0xb8, 0x5d, 0xf2, 0x26, 0x6b, 0xd5, 0x3c, 0x48, 0x37, 0x52, 0x57, 0xe9, 0x1b, 0xcd,
0x94, 0x97, 0x37, 0xd6, 0x8a, 0x59, 0xde, 0x58, 0xaf, 0xce, 0x57, 0xf7, 0x7f, 0xdc, 0x96, 0x6b,
0xf4, 0xd1, 0x78, 0x62, 0xec, 0xcf, 0xd2, 0xea, 0x33, 0xf9, 0xe7, 0xf8, 0x96, 0x52, 0x7c, 0xf8,
0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x20, 0xab, 0x70, 0x2d, 0xad, 0x0b, 0x00, 0x00,
}
+60 -50
View File
@@ -7,134 +7,144 @@ package user;
message GetAllUserIDReq{
message getAllUserIDReq{
server_api_params.RequestPagination pagination = 1;
}
message GetAllUserIDResp{
message getAllUserIDResp{
int32 total = 1;
repeated string UserIDList = 2;
repeated string userIDList = 2;
}
message AccountCheckReq{
message accountCheckReq{
repeated string checkUserIDs = 1;
}
message AccountCheckResp{
message SingleUserStatus {
message accountCheckResp{
message singleUserStatus {
string userID = 1;
string accountStatus = 2;
}
repeated SingleUserStatus results = 1;
repeated singleUserStatus results = 1;
}
message GetUsersInfoReq{
message getUsersInfoReq{
repeated string userIDs = 1;
}
message GetUsersInfoResp{
message getUsersInfoResp{
repeated server_api_params.UserInfo usersInfo = 1;
}
message UpdateUserInfoReq{
message updateUserInfoReq{
server_api_params.UserInfo userInfo = 1;
}
message UpdateUserInfoResp{
message updateUserInfoResp{
}
message SetGlobalRecvMessageOptReq{
message setGlobalRecvMessageOptReq{
string userID = 1;
int32 globalRecvMsgOpt = 3;
}
message SetGlobalRecvMessageOptResp{
message setGlobalRecvMessageOptResp{
}
message SetConversationReq{
conversation.Conversation Conversation = 1;
message setConversationReq{
conversation.Conversation conversation = 1;
int32 notificationType = 2;
string OperationID = 3;
string operationID = 3;
}
message SetConversationResp{
message setConversationResp{
}
message SetRecvMsgOptReq {
string OwnerUserID = 1;
string ConversationID = 2;
int32 RecvMsgOpt = 3;
message setRecvMsgOptReq {
string ownerUserID = 1;
string conversationID = 2;
int32 recvMsgOpt = 3;
int32 notificationType = 4;
string OperationID = 5;
string operationID = 5;
}
message SetRecvMsgOptResp {
message setRecvMsgOptResp {
}
message GetConversationReq{
string ConversationID = 1;
string OwnerUserID = 2;
string OperationID = 3;
message getConversationReq{
string conversationID = 1;
string ownerUserID = 2;
string operationID = 3;
}
message GetConversationResp{
conversation.Conversation Conversation = 2;
message getConversationResp{
conversation.Conversation conversation = 2;
}
message GetConversationsReq{
string OwnerUserID = 1;
repeated string ConversationIDs = 2;
string OperationID = 3;
message getConversationsReq{
string ownerUserID = 1;
repeated string conversationIDs = 2;
string operationID = 3;
}
message GetConversationsResp{
repeated conversation.Conversation Conversations = 2;
message getConversationsResp{
repeated conversation.Conversation conversations = 2;
}
message GetAllConversationsReq{
string OwnerUserID = 1;
string OperationID = 2;
message getAllConversationsReq{
string ownerUserID = 1;
string operationID = 2;
}
message GetAllConversationsResp{
repeated conversation.Conversation Conversations = 2;
message getAllConversationsResp{
repeated conversation.Conversation conversations = 2;
}
message BatchSetConversationsReq{
repeated conversation.Conversation Conversations = 1;
message batchSetConversationsReq{
repeated conversation.Conversation conversations = 1;
string OwnerUserID = 2;
int32 notificationType = 3;
string OperationID = 4;
}
message BatchSetConversationsResp{
message batchSetConversationsResp{
repeated string Success = 2;
repeated string Failed = 3;
}
message GetUsersReq {
message getUsersReq {
server_api_params.RequestPagination pagination = 2;
string userName = 3;
string userID = 4;
string content = 5;
}
message GetUsersResp{
message getUsersResp{
int32 total = 1;
repeated server_api_params.UserInfo users = 2;
}
message userRegisterReq {
repeated server_api_params.UserInfo users = 1;
}
message userRegisterResp {
}
service user {
//
rpc GetUsersInfo(GetUsersInfoReq) returns(GetUsersInfoResp);
rpc getUsersInfo(getUsersInfoReq) returns(getUsersInfoResp);
//
rpc UpdateUserInfo(UpdateUserInfoReq) returns(UpdateUserInfoResp);
rpc updateUserInfo(updateUserInfoReq) returns(updateUserInfoResp);
//
rpc SetGlobalRecvMessageOpt(SetGlobalRecvMessageOptReq) returns(SetGlobalRecvMessageOptResp);
rpc setGlobalRecvMessageOpt(setGlobalRecvMessageOptReq) returns(setGlobalRecvMessageOptResp);
//userID是否存在
rpc AccountCheck(AccountCheckReq)returns(AccountCheckResp);
rpc accountCheck(accountCheckReq)returns(accountCheckResp);
//userID
rpc GetUsers(GetUsersReq) returns (GetUsersResp);
rpc getUsers(getUsersReq) returns (getUsersResp);
//
rpc userRegister(userRegisterReq) returns (userRegisterResp);
}
-78
View File
@@ -1,78 +0,0 @@
package utils
import (
"Open_IM/pkg/common/config"
rocksCache "Open_IM/pkg/common/db/rocks_cache"
"Open_IM/pkg/common/log"
"Open_IM/pkg/getcdv3"
pbCache "Open_IM/pkg/proto/cache"
"context"
"errors"
"sync"
)
type GroupMemberUserIDListHash struct {
MemberListHash uint64
UserIDList []string
}
var CacheGroupMemberUserIDList = make(map[string]*GroupMemberUserIDListHash, 0)
var CacheGroupMtx sync.RWMutex
func GetGroupMemberUserIDList(ctx context.Context, groupID string, operationID string) ([]string, error) {
groupHashRemote, err := GetGroupMemberUserIDListHashFromRemote(ctx, groupID)
if err != nil {
CacheGroupMtx.Lock()
defer CacheGroupMtx.Unlock()
delete(CacheGroupMemberUserIDList, groupID)
log.Error(operationID, "GetGroupMemberUserIDListHashFromRemote failed ", err.Error(), groupID)
return nil, Wrap(err, groupID)
}
CacheGroupMtx.Lock()
defer CacheGroupMtx.Unlock()
if groupHashRemote == 0 {
log.Info(operationID, "groupHashRemote == 0 ", groupID)
delete(CacheGroupMemberUserIDList, groupID)
return []string{}, nil
}
groupInLocalCache, ok := CacheGroupMemberUserIDList[groupID]
if ok && groupInLocalCache.MemberListHash == groupHashRemote {
log.Debug(operationID, "in local cache ", groupID)
return groupInLocalCache.UserIDList, nil
}
log.Debug(operationID, "not in local cache or hash changed", groupID, " remote hash ", groupHashRemote, " in cache ", ok)
memberUserIDListRemote, err := GetGroupMemberUserIDListFromRemote(groupID, operationID)
if err != nil {
log.Error(operationID, "GetGroupMemberUserIDListFromRemote failed ", err.Error(), groupID)
return nil, Wrap(err, groupID)
}
CacheGroupMemberUserIDList[groupID] = &GroupMemberUserIDListHash{MemberListHash: groupHashRemote, UserIDList: memberUserIDListRemote}
return memberUserIDListRemote, nil
}
func GetGroupMemberUserIDListHashFromRemote(ctx context.Context, groupID string) (uint64, error) {
return rocksCache.GetGroupMemberListHashFromCache(ctx, groupID)
}
func GetGroupMemberUserIDListFromRemote(groupID string, operationID string) ([]string, error) {
getGroupMemberIDListFromCacheReq := &pbCache.GetGroupMemberIDListFromCacheReq{OperationID: operationID, GroupID: groupID}
etcdConn, err := getcdv3.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImCacheName)
if err != nil {
return nil, err
}
client := pbCache.NewCacheClient(etcdConn)
cacheResp, err := client.GetGroupMemberIDListFromCache(context.Background(), getGroupMemberIDListFromCacheReq)
if err != nil {
log.NewError(operationID, "GetGroupMemberIDListFromCache rpc call failed ", err.Error())
return nil, Wrap(err, "GetGroupMemberIDListFromCache rpc call failed")
}
if cacheResp.CommonResp.ErrCode != 0 {
errMsg := operationID + "GetGroupMemberIDListFromCache rpc logic call failed " + cacheResp.CommonResp.ErrMsg
log.NewError(operationID, errMsg)
return nil, errors.New("errMsg")
}
return cacheResp.UserIDList, nil
}