diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java index c1de10b36..034d296ef 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java @@ -24,6 +24,7 @@ import java.util.Map; import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; +import javax.annotation.Nullable; import javax.validation.Valid; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -514,6 +515,11 @@ public class AccountController { Account account = disabledPermittedAuth.getAccount(); long deviceId = disabledPermittedAuth.getAuthenticatedDevice().getId(); + // temporary: For deterministic updates during the DynamoDB migration, use a fully parameterized registration lock + @Nullable final AuthenticationCredentials registrationLockCredentials = + Util.isEmpty(attributes.getRegistrationLock()) ? null + : new AuthenticationCredentials(attributes.getRegistrationLock()); + accounts.update(account, a -> { a.getDevice(deviceId).ifPresent(d -> { d.setFetchesMessages(attributes.getFetchesMessages()); @@ -524,7 +530,14 @@ public class AccountController { d.setUserAgent(userAgent); }); - a.setRegistrationLockFromAttributes(attributes); + // temporary: for deterministic updates during the DynamoDB migration, use a fully parameterized registration lock + // a.setRegistrationLockFromAttributes(attributes); + if (registrationLockCredentials != null) { + a.setRegistrationLock(registrationLockCredentials.getHashedAuthenticationToken(), + registrationLockCredentials.getSalt()); + } else { + a.setRegistrationLock(null, null); + } a.setUnidentifiedAccessKey(attributes.getUnidentifiedAccessKey()); a.setUnrestrictedUnidentifiedAccess(attributes.isUnrestrictedUnidentifiedAccess());