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

# Conflicts:
#	pkg/common/db/cache/conversation.go
#	pkg/common/db/relation/conversation_model.go
This commit is contained in:
Gordon
2023-02-03 15:54:23 +08:00
44 changed files with 782 additions and 671 deletions
+3 -3
View File
@@ -2,7 +2,7 @@ package cache
import (
"Open_IM/pkg/common/db/relation"
"Open_IM/pkg/common/db/table"
relation2 "Open_IM/pkg/common/db/table/relation"
"Open_IM/pkg/common/tracelog"
"Open_IM/pkg/utils"
"context"
@@ -18,7 +18,7 @@ const (
)
type BlackCache struct {
blackDB *table.BlackModel
blackDB *relation2.BlackModel
expireTime time.Duration
rcClient *rockscache.Client
}
@@ -60,7 +60,7 @@ func (b *BlackCache) GetBlackIDs(ctx context.Context, userID string) (blackIDs [
func (b *BlackCache) DelBlackIDListFromCache(ctx context.Context, userID string) (err error) {
defer func() {
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "ctx", ctx)
tracelog.SetCtxDebug(ctx, utils.GetFuncName(1), err, "userID", userID)
}()
return b.rcClient.TagAsDeleted(blackListCache + userID)
}
+3 -4
View File
@@ -2,10 +2,9 @@ package cache
import (
"Open_IM/pkg/common/db/relation"
"Open_IM/pkg/common/db/table"
relation2 "Open_IM/pkg/common/db/table/relation"
"Open_IM/pkg/common/tracelog"
"Open_IM/pkg/utils"
"Open_IM/pkg/utilsv2"
"context"
"encoding/json"
"github.com/dtm-labs/rockscache"
@@ -100,7 +99,7 @@ func (f *FriendCache) DelTwoWayFriendIDs(ctx context.Context, ownerUserID string
return f.rcClient.TagAsDeleted(f.getTwoWayFriendsIDsKey(ownerUserID))
}
func (f *FriendCache) GetFriend(ctx context.Context, ownerUserID, friendUserID string) (friend *table.FriendModel, err error) {
func (f *FriendCache) GetFriend(ctx context.Context, ownerUserID, friendUserID string) (friend *relation2.FriendModel, err error) {
getFriend := func() (string, error) {
friend, err = f.friendDB.Take(ctx, ownerUserID, friendUserID)
if err != nil {
@@ -116,7 +115,7 @@ func (f *FriendCache) GetFriend(ctx context.Context, ownerUserID, friendUserID s
if err != nil {
return nil, err
}
friend = &table.FriendModel{}
friend = &relation2.FriendModel{}
err = json.Unmarshal([]byte(friendStr), friend)
return friend, utils.Wrap(err, "")
}
-2
View File
@@ -37,8 +37,6 @@ type GroupCache struct {
expireTime time.Duration
redisClient *RedisClient
rcClient *rockscache.Client
//local cache
}
func NewGroupCache(rdb redis.UniversalClient, groupDB *relation.GroupGorm, groupMemberDB *relation.GroupMemberGorm, groupRequestDB *relation.GroupRequestGorm, mongoClient *unrelation.SuperGroupMongoDriver, opts rockscache.Options) *GroupCache {
+5 -5
View File
@@ -2,7 +2,7 @@ package cache
import (
"Open_IM/pkg/common/db/relation"
"Open_IM/pkg/common/db/table"
relation2 "Open_IM/pkg/common/db/table/relation"
"Open_IM/pkg/common/tracelog"
"Open_IM/pkg/utils"
"context"
@@ -44,7 +44,7 @@ func (u *UserCache) getUserGlobalRecvMsgOptKey(userID string) string {
return userGlobalRecvMsgOptKey + userID
}
func (u *UserCache) GetUserInfo(ctx context.Context, userID string) (userInfo *table.UserModel, err error) {
func (u *UserCache) GetUserInfo(ctx context.Context, userID string) (userInfo *relation2.UserModel, err error) {
getUserInfo := func() (string, error) {
userInfo, err := u.userDB.Take(ctx, userID)
if err != nil {
@@ -63,13 +63,13 @@ func (u *UserCache) GetUserInfo(ctx context.Context, userID string) (userInfo *t
if err != nil {
return nil, err
}
userInfo = &table.UserModel{}
userInfo = &relation2.UserModel{}
err = json.Unmarshal([]byte(userInfoStr), userInfo)
return userInfo, utils.Wrap(err, "")
}
func (u *UserCache) GetUsersInfo(ctx context.Context, userIDs []string) ([]*table.UserModel, error) {
var users []*table.UserModel
func (u *UserCache) GetUsersInfo(ctx context.Context, userIDs []string) ([]*relation2.UserModel, error) {
var users []*relation2.UserModel
for _, userID := range userIDs {
user, err := GetUserInfoFromCache(ctx, userID)
if err != nil {