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 446ab5787..7966f9827 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/storage/AccountsManager.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/storage/AccountsManager.java @@ -460,6 +460,12 @@ public class AccountsManager { } try { + if (databaseAccount.getMasterDevice().isPresent() && dynamoAccount.getMasterDevice().isPresent()) { + if (!Objects.equals(databaseAccount.getMasterDevice().get().getSignedPreKey(), dynamoAccount.getMasterDevice().get().getSignedPreKey())) { + return Optional.of("masterDeviceSignedPreKey"); + } + } + if (!serializedEquals(databaseAccount.getDevices(), dynamoAccount.getDevices())) { return Optional.of("devices"); } @@ -472,10 +478,6 @@ public class AccountsManager { throw new RuntimeException(e); } - if (databaseAccount.getDynamoDbMigrationVersion() != dynamoAccount.getDynamoDbMigrationVersion()) { - return Optional.of("migrationVersion"); - } - return Optional.empty(); } diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/tests/storage/AccountsManagerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/tests/storage/AccountsManagerTest.java index d860da5a3..e795eac9c 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/tests/storage/AccountsManagerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/tests/storage/AccountsManagerTest.java @@ -32,6 +32,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicAccountsDynamoDbMigrationConfiguration; import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicConfiguration; +import org.whispersystems.textsecuregcm.entities.SignedPreKey; import org.whispersystems.textsecuregcm.experiment.ExperimentEnrollmentManager; import org.whispersystems.textsecuregcm.redis.FaultTolerantRedisCluster; import org.whispersystems.textsecuregcm.securebackup.SecureBackupClient; @@ -433,6 +434,11 @@ class AccountsManagerTest { assertEquals(Optional.of("devices"), accountsManager.compareAccounts(Optional.of(a1), Optional.of(a2))); + device1.setSignedPreKey(new SignedPreKey(1L, "123", "456")); + device2.setSignedPreKey(new SignedPreKey(2L, "123", "456")); + + assertEquals(Optional.of("masterDeviceSignedPreKey"), accountsManager.compareAccounts(Optional.of(a1), Optional.of(a2))); + a1.removeDevice(1L); a2.removeDevice(1L); @@ -443,7 +449,7 @@ class AccountsManagerTest { a1.setDynamoDbMigrationVersion(1); - assertEquals(Optional.of("migrationVersion"), accountsManager.compareAccounts(Optional.of(a1), Optional.of(a2))); + assertEquals(Optional.empty(), accountsManager.compareAccounts(Optional.of(a1), Optional.of(a2))); a2.setProfileName("name");