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) } } }