diff --git a/VERSION b/VERSION index a2bcf0450b8..fcb7188b87e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.171.5 +0.171.6 diff --git a/protocol/messenger_group_chat_test.go b/protocol/messenger_group_chat_test.go index 0dda9ef2d5f..560178c4a88 100644 --- a/protocol/messenger_group_chat_test.go +++ b/protocol/messenger_group_chat_test.go @@ -10,6 +10,7 @@ import ( "github.com/stretchr/testify/suite" userimage "github.com/status-im/status-go/images" + "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/protocol/common" "github.com/status-im/status-go/protocol/protobuf" ) @@ -454,3 +455,48 @@ func (s *MessengerGroupChatSuite) TestGroupChatMembersRemovalOutOfOrder() { defer s.NoError(admin.Shutdown()) defer s.NoError(memberA.Shutdown()) } + +func (s *MessengerGroupChatSuite) TestGroupChatMembersInfoSync() { + admin, memberA, memberB := s.startNewMessenger(), s.startNewMessenger(), s.startNewMessenger() + s.Require().NoError(admin.settings.SaveSettingField(settings.DisplayName, "admin")) + s.Require().NoError(memberA.settings.SaveSettingField(settings.DisplayName, "memberA")) + s.Require().NoError(memberB.settings.SaveSettingField(settings.DisplayName, "memberB")) + + members := []string{common.PubkeyToHex(&memberA.identity.PublicKey), common.PubkeyToHex(&memberB.identity.PublicKey)} + + s.makeMutualContacts(admin, memberA) + s.makeMutualContacts(admin, memberB) + + s.createGroupChat(admin, "test_group_chat", members) + s.verifyGroupChatCreated(memberA, true) + s.verifyGroupChatCreated(memberB, true) + + response, err := WaitOnMessengerResponse( + memberA, + func(r *MessengerResponse) bool { return len(r.Chats()) > 0 }, + "chat invitation not received", + ) + s.Require().NoError(err) + s.Require().Len(response.Chats(), 1) + s.Require().True(response.Chats()[0].Active) + s.Require().Len(response.Chats()[0].Members, 3) + + _, err = WaitOnMessengerResponse( + memberA, + func(r *MessengerResponse) bool { + // we republish as we don't have store nodes in tests + err := memberB.publishContactCode() + if err != nil { + return false + } + contact, ok := memberA.allContacts.Load(common.PubkeyToHex(&memberB.identity.PublicKey)) + return ok && contact.DisplayName == "memberB" + }, + "DisplayName is not the same", + ) + s.Require().NoError(err) + + s.NoError(admin.Shutdown()) + s.NoError(memberA.Shutdown()) + s.NoError(memberB.Shutdown()) +} diff --git a/protocol/messenger_handler.go b/protocol/messenger_handler.go index 2dfabb1b7ab..5690e7bc7af 100644 --- a/protocol/messenger_handler.go +++ b/protocol/messenger_handler.go @@ -164,6 +164,19 @@ func (m *Messenger) HandleMembershipUpdate(messageState *ReceivedMessageState, c return errors.Wrap(err, "failed to get group creator") } + publicKeys, err := group.MemberPublicKeys() + if err != nil { + return errors.Wrap(err, "failed to get group members") + } + filters, err := m.transport.JoinGroup(publicKeys) + if err != nil { + return errors.Wrap(err, "failed to join group") + } + ok, err := m.scheduleSyncFilters(filters) + if err != nil { + return errors.Wrap(err, "failed to schedule sync filter") + } + m.logger.Debug("result of schedule sync filter", zap.Bool("ok", ok)) } else { existingGroup, err := newProtocolGroupFromChat(chat) if err != nil { diff --git a/protocol/v1/membership_update_message.go b/protocol/v1/membership_update_message.go index 365c2b1997b..80c8c1a41a7 100644 --- a/protocol/v1/membership_update_message.go +++ b/protocol/v1/membership_update_message.go @@ -448,6 +448,26 @@ func (g Group) Members() []string { return g.members.List() } +func (g Group) MemberPublicKeys() ([]*ecdsa.PublicKey, error) { + var publicKeys = make([]*ecdsa.PublicKey, 0, len(g.Members())) + for _, memberPublicKey := range g.Members() { + publicKey, err := hexToPubkey(memberPublicKey) + if err != nil { + return nil, err + } + publicKeys = append(publicKeys, publicKey) + } + return publicKeys, nil +} + +func hexToPubkey(pk string) (*ecdsa.PublicKey, error) { + bytes, err := types.DecodeHex(pk) + if err != nil { + return nil, err + } + return crypto.UnmarshalPubkey(bytes) +} + func (g Group) Admins() []string { return g.admins.List() }