From c9c95b6b1ef6c805ad00b6edc7c69bca0cb5d618 Mon Sep 17 00:00:00 2001 From: a3d21 Date: Wed, 1 Nov 2023 14:09:49 +0800 Subject: [PATCH] fix: del SuperGroupRecvMsgNotNotifyUserIDs cache when conv edit --- 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 b93f0bf06..0115571fd 100644 --- a/pkg/common/db/controller/conversation.go +++ b/pkg/common/db/controller/conversation.go @@ -72,6 +72,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}) @@ -199,6 +202,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 {