From 3d3781f8d8332119356c568abe162c178a620785 Mon Sep 17 00:00:00 2001 From: a3d21 <93191329+a3d21@users.noreply.github.com> Date: Sun, 5 Nov 2023 18:48:17 +0800 Subject: [PATCH] fix: del SuperGroupRecvMsgNotNotifyUserIDs cache when conv edit (#1313) --- pkg/common/db/controller/conversation.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/common/db/controller/conversation.go b/pkg/common/db/controller/conversation.go index 4f7de5ee0..0aaa95880 100644 --- a/pkg/common/db/controller/conversation.go +++ b/pkg/common/db/controller/conversation.go @@ -74,6 +74,9 @@ type conversationDatabase struct { func (c *conversationDatabase) SetUsersConversationFiledTx(ctx context.Context, userIDs []string, conversation *relationtb.ConversationModel, filedMap map[string]interface{}) (err error) { cache := c.cache.NewCache() + if conversation.GroupID != "" { + cache = cache.DelSuperGroupRecvMsgNotNotifyUserIDs(conversation.GroupID).DelSuperGroupRecvMsgNotNotifyUserIDsHash(conversation.GroupID) + } if err := c.tx.Transaction(func(tx any) error { conversationTx := c.conversationDB.NewTx(tx) haveUserIDs, err := conversationTx.FindUserID(ctx, userIDs, []string{conversation.ConversationID}) @@ -201,6 +204,13 @@ func (c *conversationDatabase) GetUserAllConversation(ctx context.Context, owner func (c *conversationDatabase) SetUserConversations(ctx context.Context, ownerUserID string, conversations []*relationtb.ConversationModel) error { cache := c.cache.NewCache() + + groupIDs := utils.Distinct(utils.Filter(conversations, func(e *relationtb.ConversationModel) (string, bool) { + return e.GroupID, e.GroupID != "" + })) + for _, groupID := range groupIDs { + cache = cache.DelSuperGroupRecvMsgNotNotifyUserIDs(groupID).DelSuperGroupRecvMsgNotNotifyUserIDsHash(groupID) + } if err := c.tx.Transaction(func(tx any) error { var conversationIDs []string for _, conversation := range conversations {