chore_: remove EnableInstallationV2
This commit is contained in:
parent
ab9f617582
commit
abfa2ebb79
|
@ -101,7 +101,7 @@ func (s *MessengerDeleteMessageForMeSuite) Pair() {
|
||||||
s.Require().Equal("alice2", actualInstallation.InstallationMetadata.Name)
|
s.Require().Equal("alice2", actualInstallation.InstallationMetadata.Name)
|
||||||
s.Require().Equal("alice2", actualInstallation.InstallationMetadata.DeviceType)
|
s.Require().Equal("alice2", actualInstallation.InstallationMetadata.DeviceType)
|
||||||
|
|
||||||
err = s.alice1.EnableInstallation(s.alice2.installationID)
|
_, err = s.alice1.EnableInstallation(s.alice2.installationID)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ func (s *MessengerProfileDisplayNameHandlerSuite) TestDisplayNameSync() {
|
||||||
s.Require().Equal("alice's-other-device", actualInstallation.InstallationMetadata.Name)
|
s.Require().Equal("alice's-other-device", actualInstallation.InstallationMetadata.Name)
|
||||||
s.Require().Equal("alice's-other-device-type", actualInstallation.InstallationMetadata.DeviceType)
|
s.Require().Equal("alice's-other-device-type", actualInstallation.InstallationMetadata.DeviceType)
|
||||||
|
|
||||||
err = s.m.EnableInstallation(alicesOtherDevice.installationID)
|
_, err = s.m.EnableInstallation(alicesOtherDevice.installationID)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// Set new display name on alice's device
|
// Set new display name on alice's device
|
||||||
|
|
|
@ -63,7 +63,7 @@ func (s *MessengerInstallationSuite) TestReceiveInstallation() {
|
||||||
s.Require().Equal("their-name", actualInstallation.InstallationMetadata.Name)
|
s.Require().Equal("their-name", actualInstallation.InstallationMetadata.Name)
|
||||||
s.Require().Equal("their-device-type", actualInstallation.InstallationMetadata.DeviceType)
|
s.Require().Equal("their-device-type", actualInstallation.InstallationMetadata.DeviceType)
|
||||||
|
|
||||||
err = s.m.EnableInstallation(theirMessenger.installationID)
|
_, err = s.m.EnableInstallation(theirMessenger.installationID)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
contactKey, err := crypto.GenerateKey()
|
contactKey, err := crypto.GenerateKey()
|
||||||
|
@ -262,7 +262,7 @@ func (s *MessengerInstallationSuite) TestSyncInstallation() {
|
||||||
s.Require().Equal("their-name", actualInstallation.InstallationMetadata.Name)
|
s.Require().Equal("their-name", actualInstallation.InstallationMetadata.Name)
|
||||||
s.Require().Equal("their-device-type", actualInstallation.InstallationMetadata.DeviceType)
|
s.Require().Equal("their-device-type", actualInstallation.InstallationMetadata.DeviceType)
|
||||||
|
|
||||||
err = s.m.EnableInstallation(theirMessenger.installationID)
|
_, err = s.m.EnableInstallation(theirMessenger.installationID)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// sync
|
// sync
|
||||||
|
@ -382,7 +382,7 @@ func (s *MessengerInstallationSuite) TestSyncInstallationNewMessages() {
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
actualInstallation := response.Installations()[0]
|
actualInstallation := response.Installations()[0]
|
||||||
s.Require().Equal(bob2.installationID, actualInstallation.ID)
|
s.Require().Equal(bob2.installationID, actualInstallation.ID)
|
||||||
err = bob1.EnableInstallation(bob2.installationID)
|
_, err = bob1.EnableInstallation(bob2.installationID)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// send a message from bob1 to alice, it should be received on both bob1 and bob2
|
// send a message from bob1 to alice, it should be received on both bob1 and bob2
|
||||||
|
|
|
@ -22,7 +22,7 @@ func (m *Messenger) EnableInstallationAndSync(request *requests.EnableInstallati
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
installation, err := m.EnableInstallationV2(request.InstallationID)
|
installation, err := m.EnableInstallation(request.InstallationID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -503,25 +503,8 @@ func (m *Messenger) SetInstallationName(id string, name string) error {
|
||||||
return m.encryptor.SetInstallationName(m.IdentityPublicKey(), id, name)
|
return m.encryptor.SetInstallationName(m.IdentityPublicKey(), id, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: use EnableInstallationV2 instead
|
// EnableInstallation enables an installation and returns the installation
|
||||||
func (m *Messenger) EnableInstallation(id string) error {
|
func (m *Messenger) EnableInstallation(id string) (*multidevice.Installation, error) {
|
||||||
installation, ok := m.allInstallations.Load(id)
|
|
||||||
if !ok {
|
|
||||||
return errors.New("no installation found")
|
|
||||||
}
|
|
||||||
|
|
||||||
err := m.encryptor.EnableInstallation(&m.identity.PublicKey, id)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
installation.Enabled = true
|
|
||||||
// TODO(samyoul) remove storing of an updated reference pointer?
|
|
||||||
m.allInstallations.Store(id, installation)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// EnableInstallationV2 enables an installation and returns the installation
|
|
||||||
func (m *Messenger) EnableInstallationV2(id string) (*multidevice.Installation, error) {
|
|
||||||
installation, ok := m.allInstallations.Load(id)
|
installation, ok := m.allInstallations.Load(id)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, errors.New("no installation found")
|
return nil, errors.New("no installation found")
|
||||||
|
|
|
@ -60,7 +60,7 @@ func (s *MessengerSyncBookmarkSuite) TestSyncBookmark() {
|
||||||
s.Require().Equal("their-name", actualInstallation.InstallationMetadata.Name)
|
s.Require().Equal("their-name", actualInstallation.InstallationMetadata.Name)
|
||||||
s.Require().Equal("their-device-type", actualInstallation.InstallationMetadata.DeviceType)
|
s.Require().Equal("their-device-type", actualInstallation.InstallationMetadata.DeviceType)
|
||||||
|
|
||||||
err = s.m.EnableInstallation(theirMessenger.installationID)
|
_, err = s.m.EnableInstallation(theirMessenger.installationID)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// sync
|
// sync
|
||||||
|
|
|
@ -102,7 +102,7 @@ func (s *MessengerSyncChatSuite) Pair() {
|
||||||
s.Require().Equal("alice2", actualInstallation.InstallationMetadata.Name)
|
s.Require().Equal("alice2", actualInstallation.InstallationMetadata.Name)
|
||||||
s.Require().Equal("alice2", actualInstallation.InstallationMetadata.DeviceType)
|
s.Require().Equal("alice2", actualInstallation.InstallationMetadata.DeviceType)
|
||||||
|
|
||||||
err = s.alice1.EnableInstallation(s.alice2.installationID)
|
_, err = s.alice1.EnableInstallation(s.alice2.installationID)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ func (s *MessengerSyncClearHistory) pair() *Messenger {
|
||||||
s.Require().Equal("their-name", actualInstallation.InstallationMetadata.Name)
|
s.Require().Equal("their-name", actualInstallation.InstallationMetadata.Name)
|
||||||
s.Require().Equal("their-device-type", actualInstallation.InstallationMetadata.DeviceType)
|
s.Require().Equal("their-device-type", actualInstallation.InstallationMetadata.DeviceType)
|
||||||
|
|
||||||
err = s.m.EnableInstallation(theirMessenger.installationID)
|
_, err = s.m.EnableInstallation(theirMessenger.installationID)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
return theirMessenger
|
return theirMessenger
|
||||||
|
|
|
@ -70,7 +70,7 @@ func (s *MessengerSyncKeycardChangeSuite) SetupTest() {
|
||||||
)
|
)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
err = s.main.EnableInstallation(s.other.installationID)
|
_, err = s.main.EnableInstallation(s.other.installationID)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// Pre-condition - both sides have to know about keypairs migrated to a keycards
|
// Pre-condition - both sides have to know about keypairs migrated to a keycards
|
||||||
|
|
|
@ -70,7 +70,7 @@ func (s *MessengerSyncKeycardsStateSuite) SetupTest() {
|
||||||
)
|
)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
err = s.main.EnableInstallation(s.other.installationID)
|
_, err = s.main.EnableInstallation(s.other.installationID)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// Pre-condition - both sides have to know about keypairs migrated to a keycards
|
// Pre-condition - both sides have to know about keypairs migrated to a keycards
|
||||||
|
|
|
@ -55,7 +55,7 @@ func (s *MessengerSyncProfilePictureSuite) TestSyncProfilePicture() {
|
||||||
s.Require().Equal("their-name", actualInstallation.InstallationMetadata.Name)
|
s.Require().Equal("their-name", actualInstallation.InstallationMetadata.Name)
|
||||||
s.Require().Equal("their-device-type", actualInstallation.InstallationMetadata.DeviceType)
|
s.Require().Equal("their-device-type", actualInstallation.InstallationMetadata.DeviceType)
|
||||||
|
|
||||||
err = s.m.EnableInstallation(theirMessenger.installationID)
|
_, err = s.m.EnableInstallation(theirMessenger.installationID)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// Sync happens via subscription triggered from within StoreIdentityImages
|
// Sync happens via subscription triggered from within StoreIdentityImages
|
||||||
|
|
|
@ -312,7 +312,7 @@ func (m *Messenger) HandleSyncRawMessages(rawMessages []*protobuf.RawMessage) er
|
||||||
}
|
}
|
||||||
// if receiver already logged in before local pairing, we need force enable the installation,
|
// if receiver already logged in before local pairing, we need force enable the installation,
|
||||||
// AddInstallations won't make sure enable it, e.g. installation maybe already exist in db but not enabled yet
|
// AddInstallations won't make sure enable it, e.g. installation maybe already exist in db but not enabled yet
|
||||||
err = m.EnableInstallation(message.InstallationId)
|
_, err = m.EnableInstallation(message.InstallationId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ func (s *MessengerSyncSavedAddressesSuite) SetupTest() {
|
||||||
)
|
)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
err = s.main.EnableInstallation(s.other.installationID)
|
_, err = s.main.EnableInstallation(s.other.installationID)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ func (s *MessengerSyncVerificationRequests) TestSyncVerificationRequests() {
|
||||||
s.Require().Equal("their-name", actualInstallation.InstallationMetadata.Name)
|
s.Require().Equal("their-name", actualInstallation.InstallationMetadata.Name)
|
||||||
s.Require().Equal("their-device-type", actualInstallation.InstallationMetadata.DeviceType)
|
s.Require().Equal("their-device-type", actualInstallation.InstallationMetadata.DeviceType)
|
||||||
|
|
||||||
err = s.m.EnableInstallation(theirMessenger.installationID)
|
_, err = s.m.EnableInstallation(theirMessenger.installationID)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// sync
|
// sync
|
||||||
|
@ -127,7 +127,7 @@ func (s *MessengerSyncVerificationRequests) TestSyncTrust() {
|
||||||
s.Require().Equal("their-name", actualInstallation.InstallationMetadata.Name)
|
s.Require().Equal("their-name", actualInstallation.InstallationMetadata.Name)
|
||||||
s.Require().Equal("their-device-type", actualInstallation.InstallationMetadata.DeviceType)
|
s.Require().Equal("their-device-type", actualInstallation.InstallationMetadata.DeviceType)
|
||||||
|
|
||||||
err = s.m.EnableInstallation(theirMessenger.installationID)
|
_, err = s.m.EnableInstallation(theirMessenger.installationID)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// sync
|
// sync
|
||||||
|
|
|
@ -121,7 +121,7 @@ func (s *MessengerSyncWalletSuite) TestSyncWallets() {
|
||||||
s.Require().Equal("alice's-other-device", actualInstallation.InstallationMetadata.Name)
|
s.Require().Equal("alice's-other-device", actualInstallation.InstallationMetadata.Name)
|
||||||
s.Require().Equal("alice's-other-device-type", actualInstallation.InstallationMetadata.DeviceType)
|
s.Require().Equal("alice's-other-device-type", actualInstallation.InstallationMetadata.DeviceType)
|
||||||
|
|
||||||
err = s.m.EnableInstallation(alicesOtherDevice.installationID)
|
_, err = s.m.EnableInstallation(alicesOtherDevice.installationID)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// Store seed phrase keypair with accounts on alice's device
|
// Store seed phrase keypair with accounts on alice's device
|
||||||
|
@ -341,7 +341,7 @@ func (s *MessengerSyncWalletSuite) TestSyncWalletAccountsReorder() {
|
||||||
s.Require().Equal("alice's-other-device", actualInstallation.InstallationMetadata.Name)
|
s.Require().Equal("alice's-other-device", actualInstallation.InstallationMetadata.Name)
|
||||||
s.Require().Equal("alice's-other-device-type", actualInstallation.InstallationMetadata.DeviceType)
|
s.Require().Equal("alice's-other-device-type", actualInstallation.InstallationMetadata.DeviceType)
|
||||||
|
|
||||||
err = s.m.EnableInstallation(alicesOtherDevice.installationID)
|
_, err = s.m.EnableInstallation(alicesOtherDevice.installationID)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// Move down account from position 1 to position 4
|
// Move down account from position 1 to position 4
|
||||||
|
@ -531,7 +531,7 @@ func (s *MessengerSyncWalletSuite) TestSyncWalletAccountOrderAfterDeletion() {
|
||||||
s.Require().Equal("alice's-other-device", actualInstallation.InstallationMetadata.Name)
|
s.Require().Equal("alice's-other-device", actualInstallation.InstallationMetadata.Name)
|
||||||
s.Require().Equal("alice's-other-device-type", actualInstallation.InstallationMetadata.DeviceType)
|
s.Require().Equal("alice's-other-device-type", actualInstallation.InstallationMetadata.DeviceType)
|
||||||
|
|
||||||
err = s.m.EnableInstallation(alicesOtherDevice.installationID)
|
_, err = s.m.EnableInstallation(alicesOtherDevice.installationID)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// Trigger's a sync between devices
|
// Trigger's a sync between devices
|
||||||
|
|
|
@ -306,7 +306,7 @@ func PairDevices(s *suite.Suite, device1, device2 *Messenger) {
|
||||||
s.Require().NotNil(response)
|
s.Require().NotNil(response)
|
||||||
|
|
||||||
// Ensure installation is enabled
|
// Ensure installation is enabled
|
||||||
err = device2.EnableInstallation(device1.installationID)
|
_, err = device2.EnableInstallation(device1.installationID)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -940,7 +940,7 @@ func (s *SyncDeviceSuite) TestTransferringKeystoreFilesAfterStopUisngKeycard() {
|
||||||
}
|
}
|
||||||
s.Require().True(found)
|
s.Require().True(found)
|
||||||
|
|
||||||
err = serverMessenger.EnableInstallation(settings.InstallationID)
|
_, err = serverMessenger.EnableInstallation(settings.InstallationID)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// Check if the logged in account is the same on server and client
|
// Check if the logged in account is the same on server and client
|
||||||
|
|
|
@ -373,7 +373,8 @@ func (api *PublicAPI) RemoveFilters(parent context.Context, chats []*transport.F
|
||||||
|
|
||||||
// EnableInstallation enables an installation for multi-device sync.
|
// EnableInstallation enables an installation for multi-device sync.
|
||||||
func (api *PublicAPI) EnableInstallation(installationID string) error {
|
func (api *PublicAPI) EnableInstallation(installationID string) error {
|
||||||
return api.service.messenger.EnableInstallation(installationID)
|
_, err := api.service.messenger.EnableInstallation(installationID)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// DisableInstallation disables an installation for multi-device sync.
|
// DisableInstallation disables an installation for multi-device sync.
|
||||||
|
|
|
@ -332,7 +332,8 @@ func (s *Service) verifyTransactionLoop(tick time.Duration, cancel <-chan struct
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) EnableInstallation(installationID string) error {
|
func (s *Service) EnableInstallation(installationID string) error {
|
||||||
return s.messenger.EnableInstallation(installationID)
|
_, err := s.messenger.EnableInstallation(installationID)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// DisableInstallation disables an installation for multi-device sync.
|
// DisableInstallation disables an installation for multi-device sync.
|
||||||
|
|
Loading…
Reference in New Issue