Skip to content

Commit

Permalink
Feature flag automatic session reset.
Browse files Browse the repository at this point in the history
  • Loading branch information
greyson-signal committed Jan 16, 2021
1 parent 1e2590a commit a3c7e7e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.thoughtcrime.securesms.recipients.RecipientId;
import org.thoughtcrime.securesms.recipients.RecipientUtil;
import org.thoughtcrime.securesms.transport.RetryLaterException;
import org.thoughtcrime.securesms.util.FeatureFlags;
import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.signalservice.api.SignalServiceMessageSender;
import org.whispersystems.signalservice.api.crypto.UnidentifiedAccessPair;
Expand Down Expand Up @@ -82,9 +83,13 @@ private AutomaticSessionResetJob(@NonNull Parameters parameters,

@Override
protected void onRun() throws Exception {
SessionUtil.archiveSession(context, recipientId, deviceId);
insertLocalMessage();
sendNullMessage();
if (FeatureFlags.automaticSessionReset()) {
SessionUtil.archiveSession(context, recipientId, deviceId);
insertLocalMessage();
sendNullMessage();
} else {
insertLocalMessage();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public final class FeatureFlags {
private static final String SEND_VIEWED_RECEIPTS = "android.sendViewedReceipts";
private static final String CUSTOM_VIDEO_MUXER = "android.customVideoMuxer";
private static final String CDS_REFRESH_INTERVAL = "cds.syncInterval.seconds";
private static final String AUTOMATIC_SESSION_RESET = "android.automaticSessionReset";

/**
* We will only store remote values for flags in this set. If you want a flag to be controllable
Expand All @@ -90,7 +91,8 @@ public final class FeatureFlags {
SEND_VIEWED_RECEIPTS,
CUSTOM_VIDEO_MUXER,
CDS_REFRESH_INTERVAL,
GROUP_NAME_MAX_LENGTH
GROUP_NAME_MAX_LENGTH,
AUTOMATIC_SESSION_RESET
);

@VisibleForTesting
Expand Down Expand Up @@ -124,7 +126,8 @@ public final class FeatureFlags {
GV1_MIGRATION_JOB,
CUSTOM_VIDEO_MUXER,
CDS_REFRESH_INTERVAL,
GROUP_NAME_MAX_LENGTH
GROUP_NAME_MAX_LENGTH,
AUTOMATIC_SESSION_RESET
);

/**
Expand Down Expand Up @@ -285,6 +288,11 @@ public static int getMaxGroupNameGraphemeLength() {
return Math.max(32, getInteger(GROUP_NAME_MAX_LENGTH, -1));
}

/** Whether or not to allow automatic session resets. */
public static boolean automaticSessionReset() {
return getBoolean(AUTOMATIC_SESSION_RESET, true);
}

/** Only for rendering debug info. */
public static synchronized @NonNull Map<String, Object> getMemoryValues() {
return new TreeMap<>(REMOTE_VALUES);
Expand Down

0 comments on commit a3c7e7e

Please sign in to comment.