chore_: remove EnableInstallationV2

This commit is contained in:
frank 2024-09-27 06:55:03 +08:00
parent ab9f617582
commit abfa2ebb79
No known key found for this signature in database
GPG Key ID: B56FA1FC264D28FD
18 changed files with 27 additions and 42 deletions

View File

@ -101,7 +101,7 @@ func (s *MessengerDeleteMessageForMeSuite) Pair() {
s.Require().Equal("alice2", actualInstallation.InstallationMetadata.Name)
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)
}

View File

@ -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-type", actualInstallation.InstallationMetadata.DeviceType)
err = s.m.EnableInstallation(alicesOtherDevice.installationID)
_, err = s.m.EnableInstallation(alicesOtherDevice.installationID)
s.Require().NoError(err)
// Set new display name on alice's device

View File

@ -63,7 +63,7 @@ func (s *MessengerInstallationSuite) TestReceiveInstallation() {
s.Require().Equal("their-name", actualInstallation.InstallationMetadata.Name)
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)
contactKey, err := crypto.GenerateKey()
@ -262,7 +262,7 @@ func (s *MessengerInstallationSuite) TestSyncInstallation() {
s.Require().Equal("their-name", actualInstallation.InstallationMetadata.Name)
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)
// sync
@ -382,7 +382,7 @@ func (s *MessengerInstallationSuite) TestSyncInstallationNewMessages() {
s.Require().NoError(err)
actualInstallation := response.Installations()[0]
s.Require().Equal(bob2.installationID, actualInstallation.ID)
err = bob1.EnableInstallation(bob2.installationID)
_, err = bob1.EnableInstallation(bob2.installationID)
s.Require().NoError(err)
// send a message from bob1 to alice, it should be received on both bob1 and bob2

View File

@ -22,7 +22,7 @@ func (m *Messenger) EnableInstallationAndSync(request *requests.EnableInstallati
return nil, err
}
installation, err := m.EnableInstallationV2(request.InstallationID)
installation, err := m.EnableInstallation(request.InstallationID)
if err != nil {
return nil, err
}
@ -503,25 +503,8 @@ func (m *Messenger) SetInstallationName(id string, name string) error {
return m.encryptor.SetInstallationName(m.IdentityPublicKey(), id, name)
}
// Deprecated: use EnableInstallationV2 instead
func (m *Messenger) EnableInstallation(id string) 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) {
// EnableInstallation enables an installation and returns the installation
func (m *Messenger) EnableInstallation(id string) (*multidevice.Installation, error) {
installation, ok := m.allInstallations.Load(id)
if !ok {
return nil, errors.New("no installation found")

View File

@ -60,7 +60,7 @@ func (s *MessengerSyncBookmarkSuite) TestSyncBookmark() {
s.Require().Equal("their-name", actualInstallation.InstallationMetadata.Name)
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)
// sync

View File

@ -102,7 +102,7 @@ func (s *MessengerSyncChatSuite) Pair() {
s.Require().Equal("alice2", actualInstallation.InstallationMetadata.Name)
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)
}

View File

@ -49,7 +49,7 @@ func (s *MessengerSyncClearHistory) pair() *Messenger {
s.Require().Equal("their-name", actualInstallation.InstallationMetadata.Name)
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)
return theirMessenger

View File

@ -70,7 +70,7 @@ func (s *MessengerSyncKeycardChangeSuite) SetupTest() {
)
s.Require().NoError(err)
err = s.main.EnableInstallation(s.other.installationID)
_, err = s.main.EnableInstallation(s.other.installationID)
s.Require().NoError(err)
// Pre-condition - both sides have to know about keypairs migrated to a keycards

View File

@ -70,7 +70,7 @@ func (s *MessengerSyncKeycardsStateSuite) SetupTest() {
)
s.Require().NoError(err)
err = s.main.EnableInstallation(s.other.installationID)
_, err = s.main.EnableInstallation(s.other.installationID)
s.Require().NoError(err)
// Pre-condition - both sides have to know about keypairs migrated to a keycards

View File

@ -55,7 +55,7 @@ func (s *MessengerSyncProfilePictureSuite) TestSyncProfilePicture() {
s.Require().Equal("their-name", actualInstallation.InstallationMetadata.Name)
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)
// Sync happens via subscription triggered from within StoreIdentityImages

View File

@ -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,
// 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 {
return err
}

View File

@ -74,7 +74,7 @@ func (s *MessengerSyncSavedAddressesSuite) SetupTest() {
)
s.Require().NoError(err)
err = s.main.EnableInstallation(s.other.installationID)
_, err = s.main.EnableInstallation(s.other.installationID)
s.Require().NoError(err)
}

View File

@ -63,7 +63,7 @@ func (s *MessengerSyncVerificationRequests) TestSyncVerificationRequests() {
s.Require().Equal("their-name", actualInstallation.InstallationMetadata.Name)
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)
// sync
@ -127,7 +127,7 @@ func (s *MessengerSyncVerificationRequests) TestSyncTrust() {
s.Require().Equal("their-name", actualInstallation.InstallationMetadata.Name)
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)
// sync

View File

@ -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-type", actualInstallation.InstallationMetadata.DeviceType)
err = s.m.EnableInstallation(alicesOtherDevice.installationID)
_, err = s.m.EnableInstallation(alicesOtherDevice.installationID)
s.Require().NoError(err)
// 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-type", actualInstallation.InstallationMetadata.DeviceType)
err = s.m.EnableInstallation(alicesOtherDevice.installationID)
_, err = s.m.EnableInstallation(alicesOtherDevice.installationID)
s.Require().NoError(err)
// 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-type", actualInstallation.InstallationMetadata.DeviceType)
err = s.m.EnableInstallation(alicesOtherDevice.installationID)
_, err = s.m.EnableInstallation(alicesOtherDevice.installationID)
s.Require().NoError(err)
// Trigger's a sync between devices

View File

@ -306,7 +306,7 @@ func PairDevices(s *suite.Suite, device1, device2 *Messenger) {
s.Require().NotNil(response)
// Ensure installation is enabled
err = device2.EnableInstallation(device1.installationID)
_, err = device2.EnableInstallation(device1.installationID)
s.Require().NoError(err)
}

View File

@ -940,7 +940,7 @@ func (s *SyncDeviceSuite) TestTransferringKeystoreFilesAfterStopUisngKeycard() {
}
s.Require().True(found)
err = serverMessenger.EnableInstallation(settings.InstallationID)
_, err = serverMessenger.EnableInstallation(settings.InstallationID)
s.Require().NoError(err)
// Check if the logged in account is the same on server and client

View File

@ -373,7 +373,8 @@ func (api *PublicAPI) RemoveFilters(parent context.Context, chats []*transport.F
// EnableInstallation enables an installation for multi-device sync.
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.

View File

@ -332,7 +332,8 @@ func (s *Service) verifyTransactionLoop(tick time.Duration, cancel <-chan struct
}
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.