fix(sync): no AC notification(NewInstallationReceived) when targetInstallationID not match
- Add targetInstallationID parameter to SendPairInstallation function - Update protobuf SyncPairInstallation struct with TargetInstallationId field - Modify method calls across multiple test files to include new parameter - Update pairing.proto and pairing.pb.go with new field for local pairing
This commit is contained in:
parent
abfa2ebb79
commit
72c8fc5ade
|
@ -3150,6 +3150,8 @@ type ReceivedMessageState struct {
|
||||||
AllInstallations *installationMap
|
AllInstallations *installationMap
|
||||||
// List of communities modified
|
// List of communities modified
|
||||||
ModifiedInstallations *stringBoolMap
|
ModifiedInstallations *stringBoolMap
|
||||||
|
// List of installations targeted to this device modified
|
||||||
|
ModifiedInstallationsTargetedToThisDevice *stringBoolMap
|
||||||
// Map of existing messages
|
// Map of existing messages
|
||||||
ExistingMessagesMap map[string]bool
|
ExistingMessagesMap map[string]bool
|
||||||
// EmojiReactions is a list of emoji reactions for the current batch
|
// EmojiReactions is a list of emoji reactions for the current batch
|
||||||
|
@ -3322,14 +3324,15 @@ func (m *Messenger) buildMessageState() *ReceivedMessageState {
|
||||||
ModifiedContacts: new(stringBoolMap),
|
ModifiedContacts: new(stringBoolMap),
|
||||||
AllInstallations: m.allInstallations,
|
AllInstallations: m.allInstallations,
|
||||||
ModifiedInstallations: m.modifiedInstallations,
|
ModifiedInstallations: m.modifiedInstallations,
|
||||||
ExistingMessagesMap: make(map[string]bool),
|
ModifiedInstallationsTargetedToThisDevice: new(stringBoolMap),
|
||||||
EmojiReactions: make(map[string]*EmojiReaction),
|
ExistingMessagesMap: make(map[string]bool),
|
||||||
GroupChatInvitations: make(map[string]*GroupChatInvitation),
|
EmojiReactions: make(map[string]*EmojiReaction),
|
||||||
Response: &MessengerResponse{},
|
GroupChatInvitations: make(map[string]*GroupChatInvitation),
|
||||||
Timesource: m.getTimesource(),
|
Response: &MessengerResponse{},
|
||||||
ResolvePrimaryName: m.ResolvePrimaryName,
|
Timesource: m.getTimesource(),
|
||||||
AllBookmarks: make(map[string]*browsers.Bookmark),
|
ResolvePrimaryName: m.ResolvePrimaryName,
|
||||||
AllTrustStatus: make(map[string]verification.TrustStatus),
|
AllBookmarks: make(map[string]*browsers.Bookmark),
|
||||||
|
AllTrustStatus: make(map[string]verification.TrustStatus),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3735,6 +3738,7 @@ func (m *Messenger) saveDataAndPrepareResponse(messageState *ReceivedMessageStat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
targeted, _ := messageState.ModifiedInstallationsTargetedToThisDevice.Load(id)
|
||||||
if installation.Enabled {
|
if installation.Enabled {
|
||||||
// Delete AC notif since the installation is now enabled
|
// Delete AC notif since the installation is now enabled
|
||||||
err = m.deleteNotification(messageState.Response, id)
|
err = m.deleteNotification(messageState.Response, id)
|
||||||
|
@ -3742,7 +3746,7 @@ func (m *Messenger) saveDataAndPrepareResponse(messageState *ReceivedMessageStat
|
||||||
m.logger.Error("error deleting notification", zap.Error(err))
|
m.logger.Error("error deleting notification", zap.Error(err))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
} else if id != m.installationID {
|
} else if id != m.installationID && targeted {
|
||||||
// Add activity center notification when we receive a new installation
|
// Add activity center notification when we receive a new installation
|
||||||
notification := &ActivityCenterNotification{
|
notification := &ActivityCenterNotification{
|
||||||
ID: types.FromHex(id),
|
ID: types.FromHex(id),
|
||||||
|
|
|
@ -81,7 +81,7 @@ func (s *MessengerDeleteMessageForMeSuite) Pair() {
|
||||||
DeviceType: "alice2",
|
DeviceType: "alice2",
|
||||||
})
|
})
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
response, err := s.alice2.SendPairInstallation(context.Background(), nil)
|
response, err := s.alice2.SendPairInstallation(context.Background(), "", nil)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().NotNil(response)
|
s.Require().NotNil(response)
|
||||||
s.Require().Len(response.Chats(), 1)
|
s.Require().Len(response.Chats(), 1)
|
||||||
|
|
|
@ -1321,6 +1321,9 @@ func (m *Messenger) HandleSyncPairInstallation(state *ReceivedMessageState, mess
|
||||||
// TODO(samyoul) remove storing of an updated reference pointer?
|
// TODO(samyoul) remove storing of an updated reference pointer?
|
||||||
state.AllInstallations.Store(message.InstallationId, installation)
|
state.AllInstallations.Store(message.InstallationId, installation)
|
||||||
state.ModifiedInstallations.Store(message.InstallationId, true)
|
state.ModifiedInstallations.Store(message.InstallationId, true)
|
||||||
|
if message.TargetInstallationId == m.installationID {
|
||||||
|
state.ModifiedInstallationsTargetedToThisDevice.Store(message.InstallationId, true)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@ func (s *MessengerProfileDisplayNameHandlerSuite) TestDisplayNameSync() {
|
||||||
}
|
}
|
||||||
err = alicesOtherDevice.SetInstallationMetadata(alicesOtherDevice.installationID, im1)
|
err = alicesOtherDevice.SetInstallationMetadata(alicesOtherDevice.installationID, im1)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
response, err := alicesOtherDevice.SendPairInstallation(context.Background(), nil)
|
response, err := alicesOtherDevice.SendPairInstallation(context.Background(), "", nil)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().NotNil(response)
|
s.Require().NotNil(response)
|
||||||
s.Require().Len(response.Chats(), 1)
|
s.Require().Len(response.Chats(), 1)
|
||||||
|
|
|
@ -43,7 +43,7 @@ func (s *MessengerInstallationSuite) TestReceiveInstallation() {
|
||||||
DeviceType: "their-device-type",
|
DeviceType: "their-device-type",
|
||||||
})
|
})
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
response, err := theirMessenger.SendPairInstallation(context.Background(), nil)
|
response, err := theirMessenger.SendPairInstallation(context.Background(), "", nil)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().NotNil(response)
|
s.Require().NotNil(response)
|
||||||
s.Require().Len(response.Chats(), 1)
|
s.Require().Len(response.Chats(), 1)
|
||||||
|
@ -242,7 +242,7 @@ func (s *MessengerInstallationSuite) TestSyncInstallation() {
|
||||||
DeviceType: "their-device-type",
|
DeviceType: "their-device-type",
|
||||||
})
|
})
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
response, err = theirMessenger.SendPairInstallation(context.Background(), nil)
|
response, err = theirMessenger.SendPairInstallation(context.Background(), "", nil)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().NotNil(response)
|
s.Require().NotNil(response)
|
||||||
s.Require().Len(response.Chats(), 1)
|
s.Require().Len(response.Chats(), 1)
|
||||||
|
@ -366,7 +366,7 @@ func (s *MessengerInstallationSuite) TestSyncInstallationNewMessages() {
|
||||||
DeviceType: "their-device-type",
|
DeviceType: "their-device-type",
|
||||||
})
|
})
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
response, err := bob2.SendPairInstallation(context.Background(), nil)
|
response, err := bob2.SendPairInstallation(context.Background(), "", nil)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().NotNil(response)
|
s.Require().NotNil(response)
|
||||||
s.Require().Len(response.Chats(), 1)
|
s.Require().Len(response.Chats(), 1)
|
||||||
|
|
|
@ -30,7 +30,7 @@ func (m *Messenger) EnableInstallationAndSync(request *requests.EnableInstallati
|
||||||
response := &MessengerResponse{}
|
response := &MessengerResponse{}
|
||||||
response.AddInstallation(installation)
|
response.AddInstallation(installation)
|
||||||
|
|
||||||
pairResponse, err := m.SendPairInstallation(context.Background(), nil)
|
pairResponse, err := m.SendPairInstallation(context.Background(), request.InstallationID, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ func (m *Messenger) EnableInstallationAndPair(request *requests.EnableInstallati
|
||||||
i.Enabled = true
|
i.Enabled = true
|
||||||
}
|
}
|
||||||
m.allInstallations.Store(request.InstallationID, i)
|
m.allInstallations.Store(request.InstallationID, i)
|
||||||
response, err := m.SendPairInstallation(context.Background(), nil)
|
response, err := m.SendPairInstallation(context.Background(), request.GetInstallationId(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ func (m *Messenger) EnableInstallationAndPair(request *requests.EnableInstallati
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendPairInstallation sends a pair installation message
|
// SendPairInstallation sends a pair installation message
|
||||||
func (m *Messenger) SendPairInstallation(ctx context.Context, rawMessageHandler RawMessageHandler) (*MessengerResponse, error) {
|
func (m *Messenger) SendPairInstallation(ctx context.Context, targetInstallationID string, rawMessageHandler RawMessageHandler) (*MessengerResponse, error) {
|
||||||
var err error
|
var err error
|
||||||
var response MessengerResponse
|
var response MessengerResponse
|
||||||
|
|
||||||
|
@ -115,11 +115,13 @@ func (m *Messenger) SendPairInstallation(ctx context.Context, rawMessageHandler
|
||||||
clock, chat := m.getLastClockWithRelatedChat()
|
clock, chat := m.getLastClockWithRelatedChat()
|
||||||
|
|
||||||
pairMessage := &protobuf.SyncPairInstallation{
|
pairMessage := &protobuf.SyncPairInstallation{
|
||||||
Clock: clock,
|
Clock: clock,
|
||||||
Name: installation.InstallationMetadata.Name,
|
Name: installation.InstallationMetadata.Name,
|
||||||
InstallationId: installation.ID,
|
InstallationId: installation.ID,
|
||||||
DeviceType: installation.InstallationMetadata.DeviceType,
|
DeviceType: installation.InstallationMetadata.DeviceType,
|
||||||
Version: installation.Version}
|
Version: installation.Version,
|
||||||
|
TargetInstallationId: targetInstallationID,
|
||||||
|
}
|
||||||
encodedMessage, err := proto.Marshal(pairMessage)
|
encodedMessage, err := proto.Marshal(pairMessage)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -58,12 +58,41 @@ func (s *MessengerPairingSuite) TestEnableNonExistingInstallation() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestMessengerPairAfterSeedPhrase tests the scenario where alice2 wants to sync with alice1
|
func (s *MessengerPairingSuite) TestWrongTargetInstallationID() {
|
||||||
|
alice1 := s.m
|
||||||
|
alice2, err := newMessengerWithKey(s.shh, s.privateKey, s.logger, nil)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
defer TearDownMessenger(&s.Suite, alice2)
|
||||||
|
|
||||||
|
wrongTargetInstallationID := uuid.New().String()
|
||||||
|
mockRequest := requests.NewMockEnableInstallationAndPair(alice1.installationID, func() string {
|
||||||
|
return wrongTargetInstallationID
|
||||||
|
})
|
||||||
|
_, err = alice2.EnableInstallationAndPair(mockRequest)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
_, err = WaitOnMessengerResponse(
|
||||||
|
alice1,
|
||||||
|
func(r *MessengerResponse) bool {
|
||||||
|
for _, i := range r.Installations() {
|
||||||
|
// We expect the installation to be added but no activity center notification
|
||||||
|
if i.ID == alice2.installationID && len(r.ActivityCenterNotifications()) == 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
"no messages",
|
||||||
|
)
|
||||||
|
s.Require().NoError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestMessengerSyncFallback tests the scenario where alice2 wants to sync with alice1
|
||||||
// alice1 generated the connection string for bootstraping alice2
|
// alice1 generated the connection string for bootstraping alice2
|
||||||
// alice2 failed to connect to alice1 and restored from seed phrase
|
// alice2 failed to connect to alice1 and restored from seed phrase
|
||||||
// alice2 get the installationID1 from alice1 via parsing the connection string
|
// alice2 get the installationID1 from alice1 via parsing the connection string
|
||||||
// alice2 should get the display name from alice1 after pairing
|
// alice2 should get the display name from alice1 after pairing
|
||||||
func (s *MessengerPairingSuite) TestMessengerPairAfterSeedPhrase() {
|
func (s *MessengerPairingSuite) TestMessengerSyncFallback() {
|
||||||
alice1 := s.m
|
alice1 := s.m
|
||||||
alice2, err := newMessengerWithKey(s.shh, s.privateKey, s.logger, nil)
|
alice2, err := newMessengerWithKey(s.shh, s.privateKey, s.logger, nil)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
@ -92,7 +121,7 @@ func (s *MessengerPairingSuite) TestMessengerPairAfterSeedPhrase() {
|
||||||
alice1,
|
alice1,
|
||||||
func(r *MessengerResponse) bool {
|
func(r *MessengerResponse) bool {
|
||||||
for _, i := range r.Installations() {
|
for _, i := range r.Installations() {
|
||||||
if i.ID == installationID2 {
|
if i.ID == installationID2 && len(r.ActivityCenterNotifications()) == 1 && r.ActivityCenterNotifications()[0].Type == ActivityCenterNotificationTypeNewInstallationReceived {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ func (s *MessengerSyncBookmarkSuite) TestSyncBookmark() {
|
||||||
DeviceType: "their-device-type",
|
DeviceType: "their-device-type",
|
||||||
})
|
})
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
response, err := theirMessenger.SendPairInstallation(context.Background(), nil)
|
response, err := theirMessenger.SendPairInstallation(context.Background(), "", nil)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().NotNil(response)
|
s.Require().NotNil(response)
|
||||||
s.Require().Len(response.Chats(), 1)
|
s.Require().Len(response.Chats(), 1)
|
||||||
|
|
|
@ -82,7 +82,7 @@ func (s *MessengerSyncChatSuite) Pair() {
|
||||||
DeviceType: "alice2",
|
DeviceType: "alice2",
|
||||||
})
|
})
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
response, err := s.alice2.SendPairInstallation(context.Background(), nil)
|
response, err := s.alice2.SendPairInstallation(context.Background(), "", nil)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().NotNil(response)
|
s.Require().NotNil(response)
|
||||||
s.Require().Len(response.Chats(), 1)
|
s.Require().Len(response.Chats(), 1)
|
||||||
|
|
|
@ -31,7 +31,7 @@ func (s *MessengerSyncClearHistory) pair() *Messenger {
|
||||||
DeviceType: "their-device-type",
|
DeviceType: "their-device-type",
|
||||||
})
|
})
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
response, err := theirMessenger.SendPairInstallation(context.Background(), nil)
|
response, err := theirMessenger.SendPairInstallation(context.Background(), "", nil)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().NotNil(response)
|
s.Require().NotNil(response)
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ func (s *MessengerSyncKeycardChangeSuite) SetupTest() {
|
||||||
}
|
}
|
||||||
err = s.other.SetInstallationMetadata(s.other.installationID, imOther)
|
err = s.other.SetInstallationMetadata(s.other.installationID, imOther)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
response, err := s.other.SendPairInstallation(context.Background(), nil)
|
response, err := s.other.SendPairInstallation(context.Background(), "", nil)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().NotNil(response)
|
s.Require().NotNil(response)
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ func (s *MessengerSyncKeycardsStateSuite) SetupTest() {
|
||||||
}
|
}
|
||||||
err = s.other.SetInstallationMetadata(s.other.installationID, imOther)
|
err = s.other.SetInstallationMetadata(s.other.installationID, imOther)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
response, err := s.other.SendPairInstallation(context.Background(), nil)
|
response, err := s.other.SendPairInstallation(context.Background(), "", nil)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().NotNil(response)
|
s.Require().NotNil(response)
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ func (s *MessengerSyncProfilePictureSuite) TestSyncProfilePicture() {
|
||||||
DeviceType: "their-device-type",
|
DeviceType: "their-device-type",
|
||||||
})
|
})
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
response, err := theirMessenger.SendPairInstallation(context.Background(), nil)
|
response, err := theirMessenger.SendPairInstallation(context.Background(), "", nil)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().NotNil(response)
|
s.Require().NotNil(response)
|
||||||
s.Require().Len(response.Chats(), 1)
|
s.Require().Len(response.Chats(), 1)
|
||||||
|
|
|
@ -62,7 +62,7 @@ func (s *MessengerSyncSavedAddressesSuite) SetupTest() {
|
||||||
}
|
}
|
||||||
err = s.other.SetInstallationMetadata(s.other.installationID, imOther)
|
err = s.other.SetInstallationMetadata(s.other.installationID, imOther)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
response, err := s.other.SendPairInstallation(context.Background(), nil)
|
response, err := s.other.SendPairInstallation(context.Background(), "", nil)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().NotNil(response)
|
s.Require().NotNil(response)
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ func (s *MessengerSyncVerificationRequests) TestSyncVerificationRequests() {
|
||||||
DeviceType: "their-device-type",
|
DeviceType: "their-device-type",
|
||||||
})
|
})
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
response, err := theirMessenger.SendPairInstallation(context.Background(), nil)
|
response, err := theirMessenger.SendPairInstallation(context.Background(), "", nil)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().NotNil(response)
|
s.Require().NotNil(response)
|
||||||
s.Require().Len(response.Chats(), 1)
|
s.Require().Len(response.Chats(), 1)
|
||||||
|
@ -107,7 +107,7 @@ func (s *MessengerSyncVerificationRequests) TestSyncTrust() {
|
||||||
DeviceType: "their-device-type",
|
DeviceType: "their-device-type",
|
||||||
})
|
})
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
response, err := theirMessenger.SendPairInstallation(context.Background(), nil)
|
response, err := theirMessenger.SendPairInstallation(context.Background(), "", nil)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().NotNil(response)
|
s.Require().NotNil(response)
|
||||||
s.Require().Len(response.Chats(), 1)
|
s.Require().Len(response.Chats(), 1)
|
||||||
|
|
|
@ -101,7 +101,7 @@ func (s *MessengerSyncWalletSuite) TestSyncWallets() {
|
||||||
}
|
}
|
||||||
err = alicesOtherDevice.SetInstallationMetadata(alicesOtherDevice.installationID, im1)
|
err = alicesOtherDevice.SetInstallationMetadata(alicesOtherDevice.installationID, im1)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
response, err := alicesOtherDevice.SendPairInstallation(context.Background(), nil)
|
response, err := alicesOtherDevice.SendPairInstallation(context.Background(), "", nil)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().NotNil(response)
|
s.Require().NotNil(response)
|
||||||
s.Require().Len(response.Chats(), 1)
|
s.Require().Len(response.Chats(), 1)
|
||||||
|
@ -321,7 +321,7 @@ func (s *MessengerSyncWalletSuite) TestSyncWalletAccountsReorder() {
|
||||||
}
|
}
|
||||||
err = alicesOtherDevice.SetInstallationMetadata(alicesOtherDevice.installationID, im1)
|
err = alicesOtherDevice.SetInstallationMetadata(alicesOtherDevice.installationID, im1)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
response, err := alicesOtherDevice.SendPairInstallation(context.Background(), nil)
|
response, err := alicesOtherDevice.SendPairInstallation(context.Background(), "", nil)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().NotNil(response)
|
s.Require().NotNil(response)
|
||||||
s.Require().Len(response.Chats(), 1)
|
s.Require().Len(response.Chats(), 1)
|
||||||
|
@ -511,7 +511,7 @@ func (s *MessengerSyncWalletSuite) TestSyncWalletAccountOrderAfterDeletion() {
|
||||||
}
|
}
|
||||||
err = alicesOtherDevice.SetInstallationMetadata(alicesOtherDevice.installationID, im1)
|
err = alicesOtherDevice.SetInstallationMetadata(alicesOtherDevice.installationID, im1)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
response, err := alicesOtherDevice.SendPairInstallation(context.Background(), nil)
|
response, err := alicesOtherDevice.SendPairInstallation(context.Background(), "", nil)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().NotNil(response)
|
s.Require().NotNil(response)
|
||||||
s.Require().Len(response.Chats(), 1)
|
s.Require().Len(response.Chats(), 1)
|
||||||
|
|
|
@ -277,7 +277,7 @@ func FindFirstByContentType(messages []*common.Message, contentType protobuf.Cha
|
||||||
|
|
||||||
func PairDevices(s *suite.Suite, device1, device2 *Messenger) {
|
func PairDevices(s *suite.Suite, device1, device2 *Messenger) {
|
||||||
// Send pairing data
|
// Send pairing data
|
||||||
response, err := device1.SendPairInstallation(context.Background(), nil)
|
response, err := device1.SendPairInstallation(context.Background(), "", nil)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().NotNil(response)
|
s.Require().NotNil(response)
|
||||||
s.Len(response.Chats(), 1)
|
s.Len(response.Chats(), 1)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -91,8 +91,9 @@ message SyncPairInstallation {
|
||||||
string installation_id = 2;
|
string installation_id = 2;
|
||||||
string device_type = 3;
|
string device_type = 3;
|
||||||
string name = 4;
|
string name = 4;
|
||||||
// following fields used for local pairing
|
// used for local pairing
|
||||||
uint32 version = 5;
|
uint32 version = 5;
|
||||||
|
string target_installation_id = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
message SyncInstallationContactV2 {
|
message SyncInstallationContactV2 {
|
||||||
|
|
|
@ -7,7 +7,8 @@ import (
|
||||||
var ErrEnableInstallationAndPairInvalidID = errors.New("enable installation and pair: invalid installation id")
|
var ErrEnableInstallationAndPairInvalidID = errors.New("enable installation and pair: invalid installation id")
|
||||||
|
|
||||||
type EnableInstallationAndPair struct {
|
type EnableInstallationAndPair struct {
|
||||||
InstallationID string `json:"installationId"`
|
InstallationID string `json:"installationId"`
|
||||||
|
getInstallationID func() string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *EnableInstallationAndPair) Validate() error {
|
func (j *EnableInstallationAndPair) Validate() error {
|
||||||
|
@ -17,3 +18,17 @@ func (j *EnableInstallationAndPair) Validate() error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (j *EnableInstallationAndPair) GetInstallationId() string {
|
||||||
|
if j.getInstallationID != nil {
|
||||||
|
return j.getInstallationID()
|
||||||
|
}
|
||||||
|
return j.InstallationID
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewMockEnableInstallationAndPair(installationID string, mockGetInstallationID func() string) *EnableInstallationAndPair {
|
||||||
|
return &EnableInstallationAndPair{
|
||||||
|
InstallationID: installationID,
|
||||||
|
getInstallationID: mockGetInstallationID,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ func (s *SyncRawMessageHandler) CollectInstallationData(rawMessageCollector *Raw
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, err = messenger.SendPairInstallation(context.TODO(), rawMessageCollector.dispatchMessage)
|
_, err = messenger.SendPairInstallation(context.TODO(), "", rawMessageCollector.dispatchMessage)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -907,7 +907,7 @@ func (s *SyncDeviceSuite) TestTransferringKeystoreFilesAfterStopUisngKeycard() {
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
err = clientMessenger.SetInstallationMetadata(settings.InstallationID, im1)
|
err = clientMessenger.SetInstallationMetadata(settings.InstallationID, im1)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
response, err := clientMessenger.SendPairInstallation(context.Background(), nil)
|
response, err := clientMessenger.SendPairInstallation(context.Background(), "", nil)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
s.Require().NotNil(response)
|
s.Require().NotNil(response)
|
||||||
s.Require().Len(response.Chats(), 1)
|
s.Require().Len(response.Chats(), 1)
|
||||||
|
|
|
@ -1057,7 +1057,7 @@ func (api *PublicAPI) VerifiedUntrustworthy(ctx context.Context, request *reques
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *PublicAPI) SendPairInstallation(ctx context.Context) (*protocol.MessengerResponse, error) {
|
func (api *PublicAPI) SendPairInstallation(ctx context.Context) (*protocol.MessengerResponse, error) {
|
||||||
return api.service.messenger.SendPairInstallation(ctx, nil)
|
return api.service.messenger.SendPairInstallation(ctx, "", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *PublicAPI) SyncDevices(ctx context.Context, name, picture string) error {
|
func (api *PublicAPI) SyncDevices(ctx context.Context, name, picture string) error {
|
||||||
|
|
Loading…
Reference in New Issue