From cb263218475f18aa2ffe19fbfefccdaef3fd3684 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Mon, 27 Mar 2023 17:20:36 +0800 Subject: [PATCH] group --- go.mod | 2 +- go.sum | 3 ++- internal/rpc/group/callback.go | 2 +- pkg/callbackstruct/group.go | 2 +- pkg/common/db/cache/black.go | 2 +- pkg/common/db/cache/conversation.go | 2 +- pkg/common/db/cache/extend_msg_set.go | 2 +- pkg/common/db/cache/friend.go | 2 +- pkg/common/db/cache/group.go | 2 +- pkg/common/db/cache/rockscache.go | 9 +++++++-- pkg/common/db/cache/user.go | 2 +- pkg/common/db/controller/conversation.go | 4 ++-- pkg/utils/image.go | 7 +++---- 13 files changed, 23 insertions(+), 18 deletions(-) diff --git a/go.mod b/go.mod index 39a069027..58ed11d18 100644 --- a/go.mod +++ b/go.mod @@ -35,7 +35,7 @@ require ( golang.org/x/image v0.3.0 google.golang.org/api v0.103.0 google.golang.org/grpc v1.52.3 - google.golang.org/protobuf v1.28.1 + google.golang.org/protobuf v1.30.0 gopkg.in/yaml.v3 v3.0.1 gorm.io/driver/mysql v1.3.5 gorm.io/gorm v1.23.8 diff --git a/go.sum b/go.sum index ed508e08f..1e941197a 100644 --- a/go.sum +++ b/go.sum @@ -1349,8 +1349,9 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/internal/rpc/group/callback.go b/internal/rpc/group/callback.go index c66871f01..e21de6c90 100644 --- a/internal/rpc/group/callback.go +++ b/internal/rpc/group/callback.go @@ -23,7 +23,7 @@ func CallbackBeforeCreateGroup(ctx context.Context, req *group.CreateGroupReq) ( cbReq := &callbackstruct.CallbackBeforeCreateGroupReq{ CallbackCommand: constant.CallbackBeforeCreateGroupCommand, OperationID: mcontext.GetOperationID(ctx), - GroupInfo: *req.GroupInfo, + GroupInfo: req.GroupInfo, } cbReq.InitMemberList = append(cbReq.InitMemberList, &apistruct.GroupAddMemberInfo{ UserID: req.OwnerUserID, diff --git a/pkg/callbackstruct/group.go b/pkg/callbackstruct/group.go index 4a3b7edaf..1ae59e658 100644 --- a/pkg/callbackstruct/group.go +++ b/pkg/callbackstruct/group.go @@ -14,7 +14,7 @@ func (c CallbackCommand) GetCallbackCommand() string { type CallbackBeforeCreateGroupReq struct { OperationID string `json:"operationID"` CallbackCommand `json:"callbackCommand"` - common.GroupInfo + *common.GroupInfo InitMemberList []*apistruct.GroupAddMemberInfo `json:"initMemberList"` } diff --git a/pkg/common/db/cache/black.go b/pkg/common/db/cache/black.go index bd4640eba..6bf48f122 100644 --- a/pkg/common/db/cache/black.go +++ b/pkg/common/db/cache/black.go @@ -46,7 +46,7 @@ func (b *BlackCacheRedis) NewCache() BlackCache { expireTime: b.expireTime, rcClient: b.rcClient, blackDB: b.blackDB, - metaCache: NewMetaCacheRedis(b.rcClient, b.metaCache.GetPreDeleteKeys()...), + metaCache: NewMetaCacheRedis(b.rcClient, b.metaCache.GetPreDelKeys()...), } } diff --git a/pkg/common/db/cache/conversation.go b/pkg/common/db/cache/conversation.go index 57b97c165..e57f774bc 100644 --- a/pkg/common/db/cache/conversation.go +++ b/pkg/common/db/cache/conversation.go @@ -68,7 +68,7 @@ func NewNewConversationRedis(rdb redis.UniversalClient, conversationDB *relation } func (c *ConversationRedisCache) NewCache() ConversationCache { - return &ConversationRedisCache{rcClient: c.rcClient, metaCache: NewMetaCacheRedis(c.rcClient, c.metaCache.GetPreDeleteKeys()...), conversationDB: c.conversationDB, expireTime: c.expireTime} + return &ConversationRedisCache{rcClient: c.rcClient, metaCache: NewMetaCacheRedis(c.rcClient, c.metaCache.GetPreDelKeys()...), conversationDB: c.conversationDB, expireTime: c.expireTime} } func (c *ConversationRedisCache) getConversationKey(ownerUserID, conversationID string) string { diff --git a/pkg/common/db/cache/extend_msg_set.go b/pkg/common/db/cache/extend_msg_set.go index a4440437a..f7580ab0b 100644 --- a/pkg/common/db/cache/extend_msg_set.go +++ b/pkg/common/db/cache/extend_msg_set.go @@ -40,7 +40,7 @@ func NewExtendMsgSetCacheRedis(rdb redis.UniversalClient, extendMsgSetDB unrelat func (e *ExtendMsgSetCacheRedis) NewCache() ExtendMsgSetCache { return &ExtendMsgSetCacheRedis{ - metaCache: NewMetaCacheRedis(e.rcClient, e.metaCache.GetPreDeleteKeys()...), + metaCache: NewMetaCacheRedis(e.rcClient, e.metaCache.GetPreDelKeys()...), expireTime: e.expireTime, extendMsgSetDB: e.extendMsgSetDB, rcClient: e.rcClient, diff --git a/pkg/common/db/cache/friend.go b/pkg/common/db/cache/friend.go index a7540c56e..b159aeb22 100644 --- a/pkg/common/db/cache/friend.go +++ b/pkg/common/db/cache/friend.go @@ -48,7 +48,7 @@ func NewFriendCacheRedis(rdb redis.UniversalClient, friendDB relationTb.FriendMo } func (c *FriendCacheRedis) NewCache() FriendCache { - return &FriendCacheRedis{rcClient: c.rcClient, metaCache: NewMetaCacheRedis(c.rcClient, c.metaCache.GetPreDeleteKeys()...), friendDB: c.friendDB, expireTime: c.expireTime} + return &FriendCacheRedis{rcClient: c.rcClient, metaCache: NewMetaCacheRedis(c.rcClient, c.metaCache.GetPreDelKeys()...), friendDB: c.friendDB, expireTime: c.expireTime} } func (f *FriendCacheRedis) getFriendIDsKey(ownerUserID string) string { diff --git a/pkg/common/db/cache/group.go b/pkg/common/db/cache/group.go index c4c984fce..07d5cf436 100644 --- a/pkg/common/db/cache/group.go +++ b/pkg/common/db/cache/group.go @@ -74,7 +74,7 @@ func NewGroupCacheRedis(rdb redis.UniversalClient, groupDB relationTb.GroupModel } func (g *GroupCacheRedis) NewCache() GroupCache { - return &GroupCacheRedis{rcClient: g.rcClient, expireTime: g.expireTime, groupDB: g.groupDB, groupMemberDB: g.groupMemberDB, groupRequestDB: g.groupRequestDB, mongoDB: g.mongoDB, metaCache: NewMetaCacheRedis(g.rcClient, g.metaCache.GetPreDeleteKeys()...)} + return &GroupCacheRedis{rcClient: g.rcClient, expireTime: g.expireTime, groupDB: g.groupDB, groupMemberDB: g.groupMemberDB, groupRequestDB: g.groupRequestDB, mongoDB: g.mongoDB, metaCache: NewMetaCacheRedis(g.rcClient, g.metaCache.GetPreDelKeys()...)} } func (g *GroupCacheRedis) getGroupInfoKey(groupID string) string { diff --git a/pkg/common/db/cache/rockscache.go b/pkg/common/db/cache/rockscache.go index 8153245dd..72463dd5e 100644 --- a/pkg/common/db/cache/rockscache.go +++ b/pkg/common/db/cache/rockscache.go @@ -21,7 +21,8 @@ type metaCache interface { // delete key rapid DelKey(ctx context.Context, key string) error AddKeys(keys ...string) - GetPreDeleteKeys() []string + ClearKeys() + GetPreDelKeys() []string } func NewMetaCacheRedis(rcClient *rockscache.Client, keys ...string) metaCache { @@ -49,7 +50,11 @@ func (m *metaCacheRedis) AddKeys(keys ...string) { m.keys = append(m.keys, keys...) } -func (m *metaCacheRedis) GetPreDeleteKeys() []string { +func (m *metaCacheRedis) ClearKeys() { + m.keys = []string{} +} + +func (m *metaCacheRedis) GetPreDelKeys() []string { return m.keys } diff --git a/pkg/common/db/cache/user.go b/pkg/common/db/cache/user.go index 0679720d2..a14a988ef 100644 --- a/pkg/common/db/cache/user.go +++ b/pkg/common/db/cache/user.go @@ -44,7 +44,7 @@ func NewUserCacheRedis(rdb redis.UniversalClient, userDB relationTb.UserModelInt func (u *UserCacheRedis) NewCache() UserCache { return &UserCacheRedis{ - metaCache: NewMetaCacheRedis(u.rcClient, u.metaCache.GetPreDeleteKeys()...), + metaCache: NewMetaCacheRedis(u.rcClient, u.metaCache.GetPreDelKeys()...), userDB: u.userDB, expireTime: u.expireTime, rcClient: u.rcClient, diff --git a/pkg/common/db/controller/conversation.go b/pkg/common/db/controller/conversation.go index e72b06850..dd8597125 100644 --- a/pkg/common/db/controller/conversation.go +++ b/pkg/common/db/controller/conversation.go @@ -75,10 +75,10 @@ func (c *ConversationDataBase) SetUsersConversationFiledTx(ctx context.Context, return err } cache = cache.DelConversationIDs(NotUserIDs) - log.ZDebug(ctx, "SetUsersConversationFiledTx", "cache", cache.GetPreDeleteKeys(), "addr", &cache) + log.ZDebug(ctx, "SetUsersConversationFiledTx", "cache", cache.GetPreDelKeys(), "addr", &cache) } // clear cache - log.ZDebug(ctx, "SetUsersConversationFiledTx", "cache", cache.GetPreDeleteKeys(), "addr", &cache) + log.ZDebug(ctx, "SetUsersConversationFiledTx", "cache", cache.GetPreDelKeys(), "addr", &cache) return cache.DelUsersConversation(haveUserIDs, conversation.ConversationID).ExecDel(ctx) }) } diff --git a/pkg/utils/image.go b/pkg/utils/image.go index 393136e63..26060f1de 100644 --- a/pkg/utils/image.go +++ b/pkg/utils/image.go @@ -2,14 +2,15 @@ package utils import ( "errors" - "github.com/nfnt/resize" - "golang.org/x/image/bmp" "image" "image/gif" "image/jpeg" "image/png" "io" "os" + + "github.com/nfnt/resize" + "golang.org/x/image/bmp" ) func GenSmallImage(src, dst string) error { @@ -51,6 +52,4 @@ func scale(in io.Reader, out io.Writer, width, height, quality int) error { default: return errors.New("ERROR FORMAT") } - - return nil }