diff --git a/protocol/communities_messenger_test.go b/protocol/communities_messenger_test.go index fab89c9c8a5..56e8c060d58 100644 --- a/protocol/communities_messenger_test.go +++ b/protocol/communities_messenger_test.go @@ -3630,7 +3630,7 @@ func (s *MessengerCommunitiesSuite) TestHandleImport() { message.Sig = crypto.FromECDSAPub(&s.owner.identity.PublicKey) message.Payload = wrappedPayload - filter := s.alice.transport.FilterByChatID(chat.ID) + filter := s.alice.transport.FilterByChatID(community.MemberUpdateChannelID()) importedMessages := make(map[transport.Filter][]*types.Message, 0) importedMessages[*filter] = append(importedMessages[*filter], message) diff --git a/protocol/messenger_communities.go b/protocol/messenger_communities.go index 392286c74bb..2a46717d2d0 100644 --- a/protocol/messenger_communities.go +++ b/protocol/messenger_communities.go @@ -952,7 +952,7 @@ func (m *Messenger) initCommunityChats(community *communities.Community) ([]*Cha chats := CreateCommunityChats(community, m.getTimesource()) for _, chat := range chats { - publicFiltersToInit = append(publicFiltersToInit, transport.FiltersToInitialize{ChatID: chat.ID, PubsubTopic: community.PubsubTopic()}) + publicFiltersToInit = append(publicFiltersToInit, transport.FiltersToInitialize{ChatID: chat.ID, PubsubTopic: community.PubsubTopic(), ContentTopicOverrideID: community.MemberUpdateChannelID()}) } @@ -2402,7 +2402,7 @@ func (m *Messenger) CreateCommunityChat(communityID types.HexBytes, c *protobuf. for chatID, chat := range changes.ChatsAdded { c := CreateCommunityChat(changes.Community.IDString(), chatID, chat, m.getTimesource()) chats = append(chats, c) - publicFiltersToInit = append(publicFiltersToInit, transport.FiltersToInitialize{ChatID: c.ID, PubsubTopic: changes.Community.PubsubTopic()}) + publicFiltersToInit = append(publicFiltersToInit, transport.FiltersToInitialize{ChatID: c.ID, PubsubTopic: changes.Community.PubsubTopic(), ContentTopicOverrideID: changes.Community.MemberUpdateChannelID()}) response.AddChat(c) } @@ -2444,7 +2444,7 @@ func (m *Messenger) EditCommunityChat(communityID types.HexBytes, chatID string, for chatID, change := range changes.ChatsModified { c := CreateCommunityChat(community.IDString(), chatID, change.ChatModified, m.getTimesource()) chats = append(chats, c) - publicFiltersToInit = append(publicFiltersToInit, transport.FiltersToInitialize{ChatID: c.ID, PubsubTopic: community.PubsubTopic()}) + publicFiltersToInit = append(publicFiltersToInit, transport.FiltersToInitialize{ChatID: c.ID, PubsubTopic: community.PubsubTopic(), ContentTopicOverrideID: community.MemberUpdateChannelID()}) response.AddChat(c) } @@ -2498,8 +2498,8 @@ func (m *Messenger) DefaultFilters(o *communities.Community) []transport.Filters filters := []transport.FiltersToInitialize{ {ChatID: cID, PubsubTopic: communityPubsubTopic}, - {ChatID: updatesChannelID, PubsubTopic: communityPubsubTopic}, - {ChatID: mlChannelID, PubsubTopic: communityPubsubTopic}, + {ChatID: updatesChannelID, PubsubTopic: communityPubsubTopic, ContentTopicOverrideID: memberUpdateChannelID}, + {ChatID: mlChannelID, PubsubTopic: communityPubsubTopic, ContentTopicOverrideID: memberUpdateChannelID}, {ChatID: memberUpdateChannelID, PubsubTopic: communityPubsubTopic}, {ChatID: uncompressedPubKey, PubsubTopic: shard.DefaultNonProtectedPubsubTopic()}, } @@ -2725,7 +2725,7 @@ func (m *Messenger) UpdateCommunityFilters(community *communities.Community) err if err != nil { return err } - publicFiltersToInit = append(publicFiltersToInit, transport.FiltersToInitialize{ChatID: communityChatID, PubsubTopic: community.PubsubTopic()}) + publicFiltersToInit = append(publicFiltersToInit, transport.FiltersToInitialize{ChatID: communityChatID, PubsubTopic: community.PubsubTopic(), ContentTopicOverrideID: community.MemberUpdateChannelID()}) } _, err := m.transport.InitPublicFilters(publicFiltersToInit) @@ -3419,8 +3419,9 @@ func (m *Messenger) handleCommunityResponse(state *ReceivedMessageState, communi state.Response.AddChat(chat) publicFiltersToInit = append(publicFiltersToInit, transport.FiltersToInitialize{ - ChatID: chat.ID, - PubsubTopic: community.PubsubTopic(), + ChatID: chat.ID, + PubsubTopic: community.PubsubTopic(), + ContentTopicOverrideID: community.MemberUpdateChannelID(), }) // Update name, currently is the only field is mutable } else if oldChat.Name != chat.Name || diff --git a/protocol/transport/filters_manager.go b/protocol/transport/filters_manager.go index 3ac990508b0..fb00be0def6 100644 --- a/protocol/transport/filters_manager.go +++ b/protocol/transport/filters_manager.go @@ -624,8 +624,13 @@ func (f *FiltersManager) LoadContactCode(pubKey *ecdsa.PublicKey) (*Filter, erro func (f *FiltersManager) addSymmetric(chatID string, pubsubTopic string, contentTopicID string) (*RawFilter, error) { var symKeyID string var err error - - topic := ToTopic(chatID) + var topic []byte + if contentTopicID != "" { + //use override contentTopicID to generate contentTopic + topic = ToTopic(contentTopicID) + } else { + topic = ToTopic(chatID) + } topics := [][]byte{topic} symKey, ok := f.keys[chatID] @@ -650,12 +655,6 @@ func (f *FiltersManager) addSymmetric(chatID string, pubsubTopic string, content } } - if contentTopicID != "" { - //add receive filter for the single default contentTopic for all community chats - topic = ToTopic(contentTopicID) - topics = append(topics, topic) - } - id, err := f.service.Subscribe(&types.SubscriptionOptions{ SymKeyID: symKeyID, PoW: minPow,