From 47bfb25f2c96122ce2436512c209432f0718df5a Mon Sep 17 00:00:00 2001 From: Jon Chambers Date: Thu, 18 Jan 2024 13:04:23 -0500 Subject: [PATCH] Retire a now-unused transacational update method for accounts --- .../textsecuregcm/storage/AccountsManager.java | 17 +---------------- .../controllers/KeysControllerTest.java | 10 ---------- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/storage/AccountsManager.java b/service/src/main/java/org/whispersystems/textsecuregcm/storage/AccountsManager.java index defe57d5b..e9abaf518 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/storage/AccountsManager.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/storage/AccountsManager.java @@ -433,6 +433,7 @@ public class AccountsManager { final Map pniSignedPreKeys, @Nullable final Map pniPqLastResortPreKeys, final Map pniRegistrationIds) throws MismatchedDevicesException { + validateDevices(account, pniSignedPreKeys, pniPqLastResortPreKeys, pniRegistrationIds); final UUID aci = account.getIdentifier(IdentityType.ACI); @@ -843,22 +844,6 @@ public class AccountsManager { }); } - public CompletionStage updateDeviceTransactionallyAsync(final Account account, - final byte deviceId, - final Consumer deviceUpdater, - final Function> additionalWriteItemProvider) { - - final UUID uuid = account.getUuid(); - - return redisDeleteAsync(account).thenCompose(ignored -> updateTransactionallyWithRetriesAsync(account, - a -> a.getDevice(deviceId).ifPresent(deviceUpdater), - accounts::updateTransactionallyAsync, - () -> accounts.getByAccountIdentifierAsync(uuid).thenApply(Optional::orElseThrow), - a -> additionalWriteItemProvider.apply(a.getDevice(deviceId).orElseThrow()), - AccountChangeValidator.GENERAL_CHANGE_VALIDATOR, - MAX_UPDATE_ATTEMPTS)); - } - public Optional getByE164(final String number) { return getByNumberTimer.timeSupplier(() -> accounts.getByE164(number)); } diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/controllers/KeysControllerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/controllers/KeysControllerTest.java index 6cccfbdfa..008ac207b 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/controllers/KeysControllerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/controllers/KeysControllerTest.java @@ -225,16 +225,6 @@ class KeysControllerTest { when(accounts.getByServiceIdentifier(new AciServiceIdentifier(EXISTS_UUID))).thenReturn(Optional.of(existsAccount)); when(accounts.getByServiceIdentifier(new PniServiceIdentifier(EXISTS_PNI))).thenReturn(Optional.of(existsAccount)); - when(accounts.updateDeviceTransactionallyAsync(any(), anyByte(), any(), any())).thenAnswer(invocation -> { - final Account account = invocation.getArgument(0); - final byte deviceId = invocation.getArgument(1); - final Consumer deviceUpdater = invocation.getArgument(2); - - deviceUpdater.accept(account.getDevice(deviceId).orElseThrow()); - - return CompletableFuture.completedFuture(account); - }); - when(rateLimiters.getPreKeysLimiter()).thenReturn(rateLimiter); when(KEYS.storeEcOneTimePreKeys(any(), anyByte(), any()))