Make notification delay dynamically configurable

This commit is contained in:
Jon Chambers authored and Jon Chambers committed 2026-10-30 14:20:19 -04:00
1 parent 129cb9e765
commit d083eb0939
8 files changed
+48 -15

No files matched your search

@@ -1279,7 +1279,7 @@ public class WhisperServerService extends Application<WhisperServerConfiguration
webSocketEnvironment.setConnectListener(
new AuthenticatedConnectListener(accountsManager, receiptSender, messagesManager, messageMetrics, pushNotificationManager,
pushNotificationScheduler, disconnectionRequestManager,
messageDeliveryScheduler, asnInfoProviderSupplier, clientReleaseManager, experimentEnrollmentManager
messageDeliveryScheduler, asnInfoProviderSupplier, clientReleaseManager, dynamicConfigurationManager
));
webSocketEnvironment.jersey().register(new RateLimitByIpFilter(rateLimiters));
webSocketEnvironment.jersey().register(new RequestStatisticsFilter(TrafficSource.WEBSOCKET));
@@ -45,6 +45,10 @@ public class DynamicConfiguration {
@Valid
DynamicMessageDeliveryConfiguration messageDelivery = new DynamicMessageDeliveryConfiguration();
@JsonProperty
@Valid
DynamicNotificationConfiguration notifications = DynamicNotificationConfiguration.DEFAULT;
@JsonProperty
@Valid
DynamicRegistrationConfiguration registrationConfiguration = new DynamicRegistrationConfiguration(false);
@@ -115,6 +119,10 @@ public class DynamicConfiguration {
return messageDelivery;
}
public DynamicNotificationConfiguration getNotificationConfiguration() {
return notifications;
}
public DynamicRegistrationConfiguration getRegistrationConfiguration() {
return registrationConfiguration;
}
@@ -0,0 +1,21 @@
/*
* Copyright 2026 Signal Messenger, LLC
* SPDX-License-Identifier: AGPL-3.0-only
*/
package org.whispersystems.textsecuregcm.configuration.dynamic;
import jakarta.validation.constraints.NotNull;
import java.time.Duration;
public record DynamicNotificationConfiguration(@NotNull Duration undeliveredMessagesNotificationDelay) {
public static final DynamicNotificationConfiguration DEFAULT =
new DynamicNotificationConfiguration(Duration.ofMinutes(1));
public DynamicNotificationConfiguration {
if (undeliveredMessagesNotificationDelay == null) {
undeliveredMessagesNotificationDelay = DEFAULT.undeliveredMessagesNotificationDelay();
}
}
}
@@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory;
import org.whispersystems.textsecuregcm.asn.AsnInfoProvider;
import org.whispersystems.textsecuregcm.auth.AuthenticatedDevice;
import org.whispersystems.textsecuregcm.auth.DisconnectionRequestManager;
import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicConfiguration;
import org.whispersystems.textsecuregcm.experiment.ExperimentEnrollmentManager;
import org.whispersystems.textsecuregcm.identity.IdentityType;
import org.whispersystems.textsecuregcm.metrics.MessageMetrics;
@@ -24,6 +25,7 @@ import org.whispersystems.textsecuregcm.storage.Account;
import org.whispersystems.textsecuregcm.storage.AccountsManager;
import org.whispersystems.textsecuregcm.storage.ClientReleaseManager;
import org.whispersystems.textsecuregcm.storage.Device;
import org.whispersystems.textsecuregcm.storage.DynamicConfigurationManager;
import org.whispersystems.textsecuregcm.storage.MessagesManager;
import org.whispersystems.websocket.WebSocketClient;
import org.whispersystems.websocket.session.WebSocketSessionContext;
@@ -59,7 +61,7 @@ public class AuthenticatedConnectListener implements WebSocketConnectListener {
final Scheduler messageDeliveryScheduler,
final Supplier<AsnInfoProvider> asnInfoProviderSupplier,
final ClientReleaseManager clientReleaseManager,
final ExperimentEnrollmentManager experimentEnrollmentManager) {
final DynamicConfigurationManager<DynamicConfiguration> dynamicConfigurationManager) {
this(accountsManager,
disconnectionRequestManager,
@@ -76,7 +78,7 @@ public class AuthenticatedConnectListener implements WebSocketConnectListener {
client,
messageDeliveryScheduler,
clientReleaseManager,
experimentEnrollmentManager)
dynamicConfigurationManager)
);
}
@@ -25,6 +25,7 @@ import javax.annotation.Nullable;
import org.eclipse.jetty.util.ConstantThrowable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicConfiguration;
import org.whispersystems.textsecuregcm.entities.MessageProtos.Envelope;
import org.whispersystems.textsecuregcm.experiment.ExperimentEnrollmentManager;
import org.whispersystems.textsecuregcm.identity.AciServiceIdentifier;
@@ -39,6 +40,7 @@ import org.whispersystems.textsecuregcm.storage.Account;
import org.whispersystems.textsecuregcm.storage.ClientReleaseManager;
import org.whispersystems.textsecuregcm.storage.ConflictingMessageConsumerException;
import org.whispersystems.textsecuregcm.storage.Device;
import org.whispersystems.textsecuregcm.storage.DynamicConfigurationManager;
import org.whispersystems.textsecuregcm.storage.MessageStream;
import org.whispersystems.textsecuregcm.storage.MessageStreamEntry;
import org.whispersystems.textsecuregcm.storage.MessagesManager;
@@ -78,8 +80,6 @@ public class WebSocketConnection {
@VisibleForTesting
static final int MESSAGE_SENDER_MAX_CONCURRENCY = 256;
private static final Duration CLOSE_WITH_PENDING_MESSAGES_NOTIFICATION_DELAY = Duration.ofMinutes(1);
private static final Logger logger = LoggerFactory.getLogger(WebSocketConnection.class);
private static final Logger droppedErrorLogger = LoggerFactory.getLogger("droppedError");
@@ -88,7 +88,7 @@ public class WebSocketConnection {
private final MessageMetrics messageMetrics;
private final PushNotificationManager pushNotificationManager;
private final PushNotificationScheduler pushNotificationScheduler;
private final ExperimentEnrollmentManager experimentEnrollmentManager;
private final DynamicConfigurationManager<DynamicConfiguration> dynamicConfigurationManager;
private final Account authenticatedAccount;
private final Device authenticatedDevice;
@@ -114,7 +114,7 @@ public class WebSocketConnection {
final WebSocketClient client,
final Scheduler messageDeliveryScheduler,
final ClientReleaseManager clientReleaseManager,
final ExperimentEnrollmentManager experimentEnrollmentManager) {
final DynamicConfigurationManager<DynamicConfiguration> dynamicConfigurationManager) {
this.receiptSender = receiptSender;
this.messagesManager = messagesManager;
@@ -126,7 +126,7 @@ public class WebSocketConnection {
this.client = client;
this.messageDeliveryScheduler = messageDeliveryScheduler;
this.clientReleaseManager = clientReleaseManager;
this.experimentEnrollmentManager = experimentEnrollmentManager;
this.dynamicConfigurationManager = dynamicConfigurationManager;
this.messageStream =
messagesManager.getMessages(authenticatedAccount.getAccountIdentifier(), authenticatedDevice);
@@ -195,7 +195,7 @@ public class WebSocketConnection {
if (mayHaveMessages) {
pushNotificationScheduler.scheduleDelayedNotification(authenticatedAccount,
authenticatedDevice,
CLOSE_WITH_PENDING_MESSAGES_NOTIFICATION_DELAY);
dynamicConfigurationManager.getConfiguration().getNotificationConfiguration().undeliveredMessagesNotificationDelay());
}
});
}
@@ -62,6 +62,7 @@ import org.whispersystems.textsecuregcm.storage.Account;
import org.whispersystems.textsecuregcm.storage.AccountsManager;
import org.whispersystems.textsecuregcm.storage.ClientReleaseManager;
import org.whispersystems.textsecuregcm.storage.Device;
import org.whispersystems.textsecuregcm.storage.DynamicConfigurationManager;
import org.whispersystems.textsecuregcm.storage.MessageStream;
import org.whispersystems.textsecuregcm.storage.MessageStreamEntry;
import org.whispersystems.textsecuregcm.storage.MessagesManager;
@@ -131,7 +132,7 @@ class AuthenticatedConnectListenerIntegrationTest {
Schedulers.boundedElastic(),
() -> mock(AsnInfoProvider.class),
mock(ClientReleaseManager.class),
mock(ExperimentEnrollmentManager.class));
mock(DynamicConfigurationManager.class));
final WebSocketEnvironment<AuthenticatedDevice> webSocketEnvironment =
new WebSocketEnvironment<>(environment, new WebSocketConfiguration());
@@ -206,7 +206,7 @@ class WebSocketConnectionIntegrationTest {
webSocketClient,
messageDeliveryScheduler,
clientReleaseManager,
mock(ExperimentEnrollmentManager.class)
mock(DynamicConfigurationManager.class)
);
final List<MessageProtos.Envelope> expectedMessages = new ArrayList<>(dynamoDbMessageCount + foundationDbMessageCount);
@@ -291,7 +291,7 @@ class WebSocketConnectionIntegrationTest {
webSocketClient,
messageDeliveryScheduler,
clientReleaseManager,
mock(ExperimentEnrollmentManager.class)
mock(DynamicConfigurationManager.class)
);
final int dynamoDbMessageCount = 77;
@@ -412,7 +412,7 @@ class WebSocketConnectionIntegrationTest {
webSocketClient,
messageDeliveryScheduler,
clientReleaseManager,
mock(ExperimentEnrollmentManager.class)
mock(DynamicConfigurationManager.class)
);
final int dynamoDBMessageCount = 207;
@@ -499,7 +499,7 @@ class WebSocketConnectionIntegrationTest {
webSocketClient,
messageDeliveryScheduler,
clientReleaseManager,
mock(ExperimentEnrollmentManager.class));
mock(DynamicConfigurationManager.class));
final WebSocketResponseMessage successResponse = mock(WebSocketResponseMessage.class);
when(successResponse.getStatus()).thenReturn(200);
@@ -56,6 +56,7 @@ import org.whispersystems.textsecuregcm.storage.Account;
import org.whispersystems.textsecuregcm.storage.ClientReleaseManager;
import org.whispersystems.textsecuregcm.storage.ConflictingMessageConsumerException;
import org.whispersystems.textsecuregcm.storage.Device;
import org.whispersystems.textsecuregcm.storage.DynamicConfigurationManager;
import org.whispersystems.textsecuregcm.storage.MessageStream;
import org.whispersystems.textsecuregcm.storage.MessageStreamEntry;
import org.whispersystems.textsecuregcm.storage.MessagesManager;
@@ -125,7 +126,7 @@ class WebSocketConnectionTest {
client,
Schedulers.immediate(),
clientReleaseManager,
mock(ExperimentEnrollmentManager.class));
mock(DynamicConfigurationManager.class));
}
@Test