From 24d01f1ab2f8e607066900d0b7826931704fb055 Mon Sep 17 00:00:00 2001 From: Chris Eager Date: Fri, 12 Aug 2022 14:21:27 -0500 Subject: [PATCH] Revert "device capabilities: prevent `stories` downgrade" This reverts commit 1c67233eb02d33a3e686bfa7e721556e0c6e664d. --- .../textsecuregcm/controllers/DeviceController.java | 3 ++- .../org/whispersystems/textsecuregcm/storage/Account.java | 4 +++- .../tests/controllers/DeviceControllerTest.java | 5 +++-- .../textsecuregcm/tests/storage/AccountTest.java | 4 +++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/DeviceController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/DeviceController.java index d8791dce5..d8fd1691e 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/DeviceController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/DeviceController.java @@ -240,7 +240,8 @@ public class DeviceController { private boolean isCapabilityDowngrade(Account account, DeviceCapabilities capabilities, String userAgent) { boolean isDowngrade = false; - isDowngrade |= account.isStoriesSupported() && !capabilities.isStories(); + // TODO stories capability + // isDowngrade |= account.isStoriesSupported() && !capabilities.isStories(); isDowngrade |= account.isPniSupported() && !capabilities.isPni(); isDowngrade |= account.isChangeNumberSupported() && !capabilities.isChangeNumber(); isDowngrade |= account.isAnnouncementGroupSupported() && !capabilities.isAnnouncementGroup(); diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/storage/Account.java b/service/src/main/java/org/whispersystems/textsecuregcm/storage/Account.java index fb3360940..18d02560b 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/storage/Account.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/storage/Account.java @@ -209,7 +209,9 @@ public class Account { return devices.stream() .filter(Device::isEnabled) - .allMatch(device -> device.getCapabilities() != null && device.getCapabilities().isStories()); + // TODO stories capability + // .allMatch(device -> device.getCapabilities() != null && device.getCapabilities().isStories()); + .anyMatch(device -> device.getCapabilities() != null && device.getCapabilities().isStories()); } public boolean isGiftBadgesSupported() { diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/DeviceControllerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/DeviceControllerTest.java index adc2d0684..865d2ff6a 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/DeviceControllerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/DeviceControllerTest.java @@ -129,7 +129,6 @@ class DeviceControllerTest { when(account.isAnnouncementGroupSupported()).thenReturn(true); when(account.isChangeNumberSupported()).thenReturn(true); when(account.isPniSupported()).thenReturn(true); - when(account.isStoriesSupported()).thenReturn(true); when(account.isGiftBadgesSupported()).thenReturn(true); when(pendingDevicesManager.getCodeForNumber(AuthHelper.VALID_NUMBER)).thenReturn( @@ -496,7 +495,9 @@ class DeviceControllerTest { AuthHelper.getProvisioningAuthHeader(AuthHelper.VALID_NUMBER, AuthHelper.VALID_PASSWORD)) .header("User-Agent", "Signal-Android/5.42.8675309 Android/30") .put(Entity.entity(accountAttributes, MediaType.APPLICATION_JSON_TYPE)); - assertThat(response.getStatus()).isEqualTo(409); + assertThat(response.getStatus()).isEqualTo(200); // Downgrade is currently supported + // TODO stories capability + // assertThat(response.getStatus()).isEqualTo(409); deviceCapabilities = new DeviceCapabilities(true, true, true, true, true, true, true, true, true, true, true, true); accountAttributes = new AccountAttributes(false, 1234, null, null, true, deviceCapabilities); diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/tests/storage/AccountTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/tests/storage/AccountTest.java index ccfc50059..164a594e7 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/tests/storage/AccountTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/tests/storage/AccountTest.java @@ -370,7 +370,9 @@ class AccountTest { "1234".getBytes(StandardCharsets.UTF_8)).isStoriesSupported()).isTrue(); assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(), List.of(storiesCapableDevice, storiesIncapableDevice), - "1234".getBytes(StandardCharsets.UTF_8)).isStoriesSupported()).isFalse(); + "1234".getBytes(StandardCharsets.UTF_8)).isStoriesSupported()).isTrue(); + // TODO stories capability + // "1234".getBytes(StandardCharsets.UTF_8)).isStoriesSupported()).isFalse(); assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(), List.of(storiesCapableDevice, storiesIncapableExpiredDevice), "1234".getBytes(StandardCharsets.UTF_8)).isStoriesSupported()).isTrue();