fix(communities): properly delete remove chats when handling community
updates When channels where removed from communities by the community owner, community members would not remove the chats in their own databases. See https://github.com/status-im/status-desktop/issues/8000 for more info. This commit ensures that nodes delete removed chats from their local chats table and also deregister the corresponding transport filters.
This commit is contained in:
parent
2f83fb05cf
commit
019d520e28
|
@ -1600,6 +1600,20 @@ func (m *Messenger) handleCommunityDescription(state *ReceivedMessageState, sign
|
|||
return nil
|
||||
}
|
||||
|
||||
removedChatIDs := make([]string, 0)
|
||||
for id := range communityResponse.Changes.ChatsRemoved {
|
||||
chatID := community.IDString() + id
|
||||
_, ok := state.AllChats.Load(chatID)
|
||||
if ok {
|
||||
removedChatIDs = append(removedChatIDs, chatID)
|
||||
state.AllChats.Delete(chatID)
|
||||
err := m.DeleteChat(chatID)
|
||||
if err != nil {
|
||||
m.logger.Error("couldn't delete chat", zap.Error(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update relevant chats names and add new ones
|
||||
// Currently removal is not supported
|
||||
chats := CreateCommunityChats(community, state.Timesource)
|
||||
|
@ -1629,6 +1643,13 @@ func (m *Messenger) handleCommunityDescription(state *ReceivedMessageState, sign
|
|||
}
|
||||
}
|
||||
|
||||
for _, chatID := range removedChatIDs {
|
||||
_, err := m.transport.RemoveFilterByChatID(chatID)
|
||||
if err != nil {
|
||||
m.logger.Error("couldn't remove filter", zap.Error(err))
|
||||
}
|
||||
}
|
||||
|
||||
// Load transport filters
|
||||
filters, err := m.transport.InitPublicFilters(chatIDs)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue