0
0
mirror of https://github.com/signalapp/Signal-Server.git synced 2024-09-20 12:02:18 +02:00

Add a "doomsday switch."

This commit is contained in:
Jon Chambers 2021-01-15 17:51:38 -05:00 committed by Jon Chambers
parent 59eb6d10c1
commit 0a322d5a9f

View File

@ -88,7 +88,6 @@ public class MessageController {
private final ApnFallbackManager apnFallbackManager;
private final FeatureFlagsManager featureFlagsManager;
private final Random random = new Random();
private static final String CONTENT_SIZE_DISTRIBUTION_NAME = name(MessageController.class, "messageContentSize");
private static final String OUTGOING_MESSAGE_LIST_SIZE_BYTES_DISTRIBUTION_NAME = name(MessageController.class, "outgoingMessageListSizeBytes");
@ -194,15 +193,21 @@ public class MessageController {
.type(MediaType.APPLICATION_JSON)
.entity(new StaleDevices(e.getStaleDevices()))
.build());
} } else {
return Response.status(503).build();
}
} else {
if (featureFlagsManager.isFeatureFlagActive("SEND_ALL_200_STATUS")) {
// Forgive me for what I must do
return Response.ok(new SendMessageResponse(false)).build();
} else {
return Response.status(503).build();
}
}
}
private boolean shouldSend(final AmbiguousIdentifier destination) {
final double hash = destination.sendingGateHash();
return (hash / 255.0) <= getSuccessPercentage();
return (hash / 256.0) < getSuccessPercentage();
}
private double getSuccessPercentage() {