From ce7514718660355e5c8f0c2776b496d5eac90b2c Mon Sep 17 00:00:00 2001 From: Jon Chambers Date: Fri, 30 Oct 2026 16:02:02 -0400 Subject: [PATCH] Add a dynamic configuration switch to send "you still have messages" notifications immediately --- .../DynamicNotificationConfiguration.java | 13 ++----------- .../websocket/WebSocketConnection.java | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/configuration/dynamic/DynamicNotificationConfiguration.java b/service/src/main/java/org/whispersystems/textsecuregcm/configuration/dynamic/DynamicNotificationConfiguration.java index f5215fbcf..e52c4ad4c 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/configuration/dynamic/DynamicNotificationConfiguration.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/configuration/dynamic/DynamicNotificationConfiguration.java @@ -5,17 +5,8 @@ package org.whispersystems.textsecuregcm.configuration.dynamic; -import jakarta.validation.constraints.NotNull; -import java.time.Duration; - -public record DynamicNotificationConfiguration(@NotNull Duration undeliveredMessagesNotificationDelay) { +public record DynamicNotificationConfiguration(boolean sendRemainingMessagesNotificationImmediately) { public static final DynamicNotificationConfiguration DEFAULT = - new DynamicNotificationConfiguration(Duration.ofMinutes(1)); - - public DynamicNotificationConfiguration { - if (undeliveredMessagesNotificationDelay == null) { - undeliveredMessagesNotificationDelay = DEFAULT.undeliveredMessagesNotificationDelay(); - } - } + new DynamicNotificationConfiguration(false); } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/websocket/WebSocketConnection.java b/service/src/main/java/org/whispersystems/textsecuregcm/websocket/WebSocketConnection.java index c34ae2f94..ba6f47147 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/websocket/WebSocketConnection.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/websocket/WebSocketConnection.java @@ -27,12 +27,12 @@ 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; import org.whispersystems.textsecuregcm.identity.ServiceIdentifier; import org.whispersystems.textsecuregcm.metrics.MessageMetrics; import org.whispersystems.textsecuregcm.metrics.MetricsUtil; import org.whispersystems.textsecuregcm.metrics.UserAgentTagUtil; +import org.whispersystems.textsecuregcm.push.NotPushRegisteredException; import org.whispersystems.textsecuregcm.push.PushNotificationManager; import org.whispersystems.textsecuregcm.push.PushNotificationScheduler; import org.whispersystems.textsecuregcm.push.ReceiptSender; @@ -80,6 +80,8 @@ 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"); @@ -193,9 +195,18 @@ public class WebSocketConnection { messagesManager.mayHaveMessages(authenticatedAccount.getAccountIdentifier(), authenticatedDevice) .thenAccept(mayHaveMessages -> { if (mayHaveMessages) { - pushNotificationScheduler.scheduleDelayedNotification(authenticatedAccount, - authenticatedDevice, - dynamicConfigurationManager.getConfiguration().getNotificationConfiguration().undeliveredMessagesNotificationDelay()); + if (dynamicConfigurationManager.getConfiguration().getNotificationConfiguration().sendRemainingMessagesNotificationImmediately()) { + try { + pushNotificationManager.sendNewMessageNotification(authenticatedAccount, + authenticatedDevice.getId(), + true); + } catch (NotPushRegisteredException _) { + } + } else { + pushNotificationScheduler.scheduleDelayedNotification(authenticatedAccount, + authenticatedDevice, + CLOSE_WITH_PENDING_MESSAGES_NOTIFICATION_DELAY); + } } }); }