From 1b5c60235194018012841501ade88c38442af365 Mon Sep 17 00:00:00 2001 From: Jon Chambers Date: Thu, 16 Apr 2026 12:19:13 -0400 Subject: [PATCH] Retire the device count override system --- .../WhisperServerConfiguration.java | 20 ------------- .../textsecuregcm/WhisperServerService.java | 2 +- .../configuration/MaxDeviceConfiguration.java | 30 ------------------- .../controllers/DeviceController.java | 21 ++++--------- .../controllers/DeviceControllerTest.java | 6 +--- 5 files changed, 7 insertions(+), 72 deletions(-) delete mode 100644 service/src/main/java/org/whispersystems/textsecuregcm/configuration/MaxDeviceConfiguration.java diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java index a050583fb..76e4dcd89 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerConfiguration.java @@ -10,9 +10,6 @@ import jakarta.validation.Valid; import jakarta.validation.constraints.NotNull; import java.time.Duration; import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; import java.util.Map; import org.whispersystems.textsecuregcm.attachments.TusConfiguration; import org.whispersystems.textsecuregcm.configuration.ApnConfiguration; @@ -44,7 +41,6 @@ import org.whispersystems.textsecuregcm.configuration.HlrLookupConfiguration; import org.whispersystems.textsecuregcm.configuration.IdlePrimaryDeviceReminderConfiguration; import org.whispersystems.textsecuregcm.configuration.KeyTransparencyServiceConfiguration; import org.whispersystems.textsecuregcm.configuration.LinkDeviceSecretConfiguration; -import org.whispersystems.textsecuregcm.configuration.MaxDeviceConfiguration; import org.whispersystems.textsecuregcm.configuration.MessageByteLimitCardinalityEstimatorConfiguration; import org.whispersystems.textsecuregcm.configuration.MessageCacheConfiguration; import org.whispersystems.textsecuregcm.configuration.OneTimeDonationConfiguration; @@ -187,11 +183,6 @@ public class WhisperServerConfiguration extends Configuration { @JsonProperty private MessageCacheConfiguration messageCache; - @Valid - @NotNull - @JsonProperty - private List maxDevices = new LinkedList<>(); - @Valid @NotNull @JsonProperty @@ -480,17 +471,6 @@ public class WhisperServerConfiguration extends Configuration { return unidentifiedDelivery; } - public Map getMaxDevices() { - Map results = new HashMap<>(); - - for (MaxDeviceConfiguration maxDeviceConfiguration : maxDevices) { - results.put(maxDeviceConfiguration.getNumber(), - maxDeviceConfiguration.getCount()); - } - - return results; - } - public PaymentsServiceConfiguration getPaymentsServiceConfiguration() { return paymentsService; } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java index c97d94cab..d02fa95cc 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java @@ -1105,7 +1105,7 @@ public class WhisperServerService extends Application maxDeviceConfiguration; private final EnumMap linkedDeviceListenersByPlatform; private final AtomicInteger linkedDeviceListenersForUnrecognizedPlatforms; @@ -117,13 +116,11 @@ public class DeviceController { public DeviceController(final AccountsManager accounts, final RateLimiters rateLimiters, - final PersistentTimer persistentTimer, - final Map maxDeviceConfiguration) { + final PersistentTimer persistentTimer) { this.accounts = accounts; this.rateLimiters = rateLimiters; this.persistentTimer = persistentTimer; - this.maxDeviceConfiguration = maxDeviceConfiguration; linkedDeviceListenersByPlatform = EnumMapUtil.toEnumMap(ClientPlatform.class, clientPlatform -> buildGauge(clientPlatform.name().toLowerCase())); @@ -204,14 +201,8 @@ public class DeviceController { rateLimiters.getAllocateDeviceLimiter().validate(account.getUuid()); - int maxDeviceLimit = MAX_DEVICES; - - if (maxDeviceConfiguration.containsKey(account.getNumber())) { - maxDeviceLimit = maxDeviceConfiguration.get(account.getNumber()); - } - - if (account.getDevices().size() >= maxDeviceLimit) { - throw new DeviceLimitExceededException(account.getDevices().size(), maxDeviceLimit); + if (account.getDevices().size() >= MAX_DEVICES) { + throw new DeviceLimitExceededException(account.getDevices().size(), MAX_DEVICES); } if (auth.deviceId() != Device.PRIMARY_ID) { @@ -268,10 +259,8 @@ public class DeviceController { throw new WebApplicationException(Response.status(422).build()); } - final int maxDeviceLimit = maxDeviceConfiguration.getOrDefault(account.getNumber(), MAX_DEVICES); - - if (account.getDevices().size() >= maxDeviceLimit) { - throw new DeviceLimitExceededException(account.getDevices().size(), maxDeviceLimit); + if (account.getDevices().size() >= MAX_DEVICES) { + throw new DeviceLimitExceededException(account.getDevices().size(), MAX_DEVICES); } final Set capabilities = accountAttributes.getCapabilities(); diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/controllers/DeviceControllerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/controllers/DeviceControllerTest.java index 0208c66cf..7c0692452 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/controllers/DeviceControllerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/controllers/DeviceControllerTest.java @@ -35,9 +35,7 @@ import java.time.temporal.ChronoUnit; import java.util.Arrays; import java.util.Base64; import java.util.EnumSet; -import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.concurrent.CompletableFuture; @@ -111,7 +109,6 @@ class DeviceControllerTest { private static final Account account = mock(Account.class); private static final Account maxedAccount = mock(Account.class); private static final Device primaryDevice = mock(Device.class); - private static final Map deviceConfiguration = new HashMap<>(); private static final TestClock testClock = TestClock.now(); private static final byte NEXT_DEVICE_ID = 42; @@ -119,8 +116,7 @@ class DeviceControllerTest { private static final DeviceController deviceController = new DeviceController( accountsManager, rateLimiters, - persistentTimer, - deviceConfiguration); + persistentTimer); private static final ResourceExtension resources = ResourceExtension.builder() .addProperty(ServerProperties.UNWRAP_COMPLETION_STAGE_IN_WRITER_ENABLE, Boolean.TRUE)