From a5a3fdf688cacac0f9d0f397af13cf5078de5dc0 Mon Sep 17 00:00:00 2001 From: Bohdan Horbeshko Date: Fri, 9 May 2025 22:32:17 -0400 Subject: [PATCH] Purge delayed statuses for legacy groups before migration --- telegram/utils.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/telegram/utils.go b/telegram/utils.go index b158c71..ee3bc8b 100644 --- a/telegram/utils.go +++ b/telegram/utils.go @@ -2354,10 +2354,21 @@ func (c *Client) GetChatMembers(chatID int64, limited bool, query string, member // MigrateToMUCs unsubscribes from legacy group chats and invites to MUCs func (c *Client) MigrateToMUCs() { + var chatIDs []int64 for _, chat := range c.GetGroupChats() { - c.unsubscribe(chat.Id) + chatIDs = append(chatIDs, chat.Id) + } + + c.DelayedStatusesLock.Lock() + for _, chatID := range chatIDs { + delete(c.DelayedStatuses, chatID) + } + c.DelayedStatusesLock.Unlock() + + for _, chatID := range chatIDs { + c.unsubscribe(chatID) for resource := range c.resourcesRange() { - gateway.InviteToMUC(chat.Id, c.jid+"/"+resource, c.xmpp) + gateway.InviteToMUC(chatID, c.jid+"/"+resource, c.xmpp) } } }