From 95c19b7fac3c4d0705c9b25bb37deb7e1b98330e Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Fri, 30 Jun 2023 19:28:08 +0800 Subject: [PATCH] fix: delete conversation empty cache --- pkg/common/db/controller/conversation.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/common/db/controller/conversation.go b/pkg/common/db/controller/conversation.go index d7e955e6b..9845d268b 100644 --- a/pkg/common/db/controller/conversation.go +++ b/pkg/common/db/controller/conversation.go @@ -87,7 +87,7 @@ func (c *conversationDatabase) SetUsersConversationFiledTx(ctx context.Context, if err != nil { return err } - cache = cache.DelConversationIDs(NotUserIDs...).DelUserConversationIDsHash(NotUserIDs...) + cache = cache.DelConversationIDs(NotUserIDs...).DelUserConversationIDsHash(NotUserIDs...).DelConvsersations(conversation.ConversationID, NotUserIDs...) } return nil }); err != nil { @@ -194,6 +194,7 @@ func (c *conversationDatabase) SetUserConversations(ctx context.Context, ownerUs for _, conversation := range conversations { if !utils.IsContain(conversation.ConversationID, existConversationIDs) { notExistConversations = append(notExistConversations, conversation) + cache = cache.DelConvsersations(ownerUserID, conversation.ConversationID) } } if len(notExistConversations) > 0 { @@ -228,6 +229,7 @@ func (c *conversationDatabase) CreateGroupChatConversation(ctx context.Context, for _, v := range notExistUserIDs { conversation := relationTb.ConversationModel{ConversationType: constant.SuperGroupChatType, GroupID: groupID, OwnerUserID: v, ConversationID: conversationID} conversations = append(conversations, &conversation) + cache = cache.DelConvsersations(v, conversationID) } cache = cache.DelConversationIDs(notExistUserIDs...).DelUserConversationIDsHash(notExistUserIDs...) if len(conversations) > 0 {