mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 05:38:04 +01:00
Retire the "notify idle devices with messages" experiment
This commit is contained in:
committed by
Jon Chambers
parent
694a93db6d
commit
d91a6b0c38
@@ -261,11 +261,8 @@ import org.whispersystems.textsecuregcm.workers.BackupMetricsCommand;
|
||||
import org.whispersystems.textsecuregcm.workers.CertificateCommand;
|
||||
import org.whispersystems.textsecuregcm.workers.CheckDynamicConfigurationCommand;
|
||||
import org.whispersystems.textsecuregcm.workers.DeleteUserCommand;
|
||||
import org.whispersystems.textsecuregcm.workers.DiscardPushNotificationExperimentSamplesCommand;
|
||||
import org.whispersystems.textsecuregcm.workers.FinishPushNotificationExperimentCommand;
|
||||
import org.whispersystems.textsecuregcm.workers.IdleDeviceNotificationSchedulerFactory;
|
||||
import org.whispersystems.textsecuregcm.workers.MessagePersisterServiceCommand;
|
||||
import org.whispersystems.textsecuregcm.workers.NotifyIdleDevicesWithMessagesExperimentFactory;
|
||||
import org.whispersystems.textsecuregcm.workers.NotifyIdleDevicesWithoutMessagesCommand;
|
||||
import org.whispersystems.textsecuregcm.workers.ProcessScheduledJobsServiceCommand;
|
||||
import org.whispersystems.textsecuregcm.workers.RemoveExpiredAccountsCommand;
|
||||
@@ -276,7 +273,6 @@ import org.whispersystems.textsecuregcm.workers.ScheduledApnPushNotificationSend
|
||||
import org.whispersystems.textsecuregcm.workers.ServerVersionCommand;
|
||||
import org.whispersystems.textsecuregcm.workers.SetRequestLoggingEnabledTask;
|
||||
import org.whispersystems.textsecuregcm.workers.SetUserDiscoverabilityCommand;
|
||||
import org.whispersystems.textsecuregcm.workers.StartPushNotificationExperimentCommand;
|
||||
import org.whispersystems.textsecuregcm.workers.UnlinkDeviceCommand;
|
||||
import org.whispersystems.textsecuregcm.workers.ZkParamsCommand;
|
||||
import org.whispersystems.websocket.WebSocketResourceProviderFactory;
|
||||
@@ -334,21 +330,6 @@ public class WhisperServerService extends Application<WhisperServerConfiguration
|
||||
bootstrap.addCommand(new ProcessScheduledJobsServiceCommand("process-idle-device-notification-jobs",
|
||||
"Processes scheduled jobs to send notifications to idle devices",
|
||||
new IdleDeviceNotificationSchedulerFactory()));
|
||||
|
||||
bootstrap.addCommand(
|
||||
new StartPushNotificationExperimentCommand<>("start-notify-idle-devices-with-messages-experiment",
|
||||
"Start an experiment to send push notifications to idle devices with pending messages",
|
||||
new NotifyIdleDevicesWithMessagesExperimentFactory()));
|
||||
|
||||
bootstrap.addCommand(
|
||||
new FinishPushNotificationExperimentCommand<>("finish-notify-idle-devices-with-messages-experiment",
|
||||
"Finish an experiment to send push notifications to idle devices with pending messages",
|
||||
new NotifyIdleDevicesWithMessagesExperimentFactory()));
|
||||
|
||||
bootstrap.addCommand(
|
||||
new DiscardPushNotificationExperimentSamplesCommand("discard-notify-idle-devices-with-messages-samples",
|
||||
"Discard samples from the \"notify idle devices with messages\" experiment",
|
||||
new NotifyIdleDevicesWithMessagesExperimentFactory()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
package org.whispersystems.textsecuregcm.experiment;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import org.whispersystems.textsecuregcm.entities.MessageProtos;
|
||||
import org.whispersystems.textsecuregcm.identity.IdentityType;
|
||||
import org.whispersystems.textsecuregcm.push.IdleDeviceNotificationScheduler;
|
||||
import org.whispersystems.textsecuregcm.storage.Account;
|
||||
import org.whispersystems.textsecuregcm.storage.Device;
|
||||
import org.whispersystems.textsecuregcm.storage.MessagesManager;
|
||||
import reactor.core.publisher.Flux;
|
||||
import java.time.Clock;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalTime;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class NotifyIdleDevicesWithMessagesExperiment extends IdleDevicePushNotificationExperiment {
|
||||
|
||||
private final IdleDeviceNotificationScheduler idleDeviceNotificationScheduler;
|
||||
private final MessagesManager messagesManager;
|
||||
|
||||
@VisibleForTesting
|
||||
static final Duration MIN_IDLE_DURATION = Duration.ofDays(3);
|
||||
|
||||
@VisibleForTesting
|
||||
static final Duration MAX_IDLE_DURATION = Duration.ofDays(14);
|
||||
|
||||
@VisibleForTesting
|
||||
static final LocalTime PREFERRED_NOTIFICATION_TIME = LocalTime.of(14, 0);
|
||||
|
||||
public NotifyIdleDevicesWithMessagesExperiment(final IdleDeviceNotificationScheduler idleDeviceNotificationScheduler,
|
||||
final MessagesManager messagesManager,
|
||||
final Clock clock) {
|
||||
|
||||
super(clock);
|
||||
|
||||
this.idleDeviceNotificationScheduler = idleDeviceNotificationScheduler;
|
||||
this.messagesManager = messagesManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Duration getMinIdleDuration() {
|
||||
return MIN_IDLE_DURATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Duration getMaxIdleDuration() {
|
||||
return MAX_IDLE_DURATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExperimentName() {
|
||||
return "notify-idle-devices-with-messages";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> isDeviceEligible(final Account account, final Device device) {
|
||||
|
||||
if (!device.isPrimary()) {
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
|
||||
if (!hasPushToken(device)) {
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
|
||||
if (!isIdle(device)) {
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
|
||||
return Flux.from(messagesManager.getMessagesForDeviceReactive(account.getIdentifier(IdentityType.ACI), device, false))
|
||||
.any(MessageProtos.Envelope::getUrgent)
|
||||
.toFuture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<DeviceLastSeenState> getStateClass() {
|
||||
return DeviceLastSeenState.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> applyExperimentTreatment(final Account account, final Device device) {
|
||||
return idleDeviceNotificationScheduler.scheduleNotification(account, device, PREFERRED_NOTIFICATION_TIME);
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package org.whispersystems.textsecuregcm.workers;
|
||||
|
||||
import org.whispersystems.textsecuregcm.WhisperServerConfiguration;
|
||||
import org.whispersystems.textsecuregcm.configuration.DynamoDbTables;
|
||||
import org.whispersystems.textsecuregcm.experiment.DeviceLastSeenState;
|
||||
import org.whispersystems.textsecuregcm.experiment.NotifyIdleDevicesWithMessagesExperiment;
|
||||
import org.whispersystems.textsecuregcm.experiment.PushNotificationExperiment;
|
||||
import org.whispersystems.textsecuregcm.push.IdleDeviceNotificationScheduler;
|
||||
import java.time.Clock;
|
||||
|
||||
public class NotifyIdleDevicesWithMessagesExperimentFactory implements PushNotificationExperimentFactory<DeviceLastSeenState> {
|
||||
|
||||
@Override
|
||||
public PushNotificationExperiment<DeviceLastSeenState> buildExperiment(final CommandDependencies commandDependencies,
|
||||
final WhisperServerConfiguration configuration) {
|
||||
|
||||
final DynamoDbTables.TableWithExpiration tableConfiguration = configuration.getDynamoDbTables().getScheduledJobs();
|
||||
|
||||
final Clock clock = Clock.systemUTC();
|
||||
|
||||
return new NotifyIdleDevicesWithMessagesExperiment(new IdleDeviceNotificationScheduler(
|
||||
commandDependencies.accountsManager(),
|
||||
commandDependencies.pushNotificationManager(),
|
||||
commandDependencies.dynamoDbAsyncClient(),
|
||||
tableConfiguration.getTableName(),
|
||||
tableConfiguration.getExpiration(),
|
||||
clock),
|
||||
commandDependencies.messagesManager(),
|
||||
clock);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user