Avoid setting the isStory field in an Envelope when possible

This commit is contained in:
Jordan Rose
2025-06-18 13:31:14 -07:00
committed by Chris Eager
parent b8e8fd3313
commit dc3920a99c
7 changed files with 30 additions and 13 deletions

View File

@@ -51,10 +51,14 @@ public record IncomingMessage(int type,
.setClientTimestamp(timestamp)
.setServerTimestamp(clock.millis())
.setDestinationServiceId(destinationIdentifier.toServiceIdentifierString())
.setStory(story)
.setEphemeral(ephemeral)
.setUrgent(urgent);
if (story) {
// Avoid sending this field if it's false.
envelopeBuilder.setStory(true);
}
if (sourceServiceIdentifier != null && sourceDeviceId != null) {
envelopeBuilder
.setSourceServiceId(sourceServiceIdentifier.toServiceIdentifierString())

View File

@@ -46,9 +46,13 @@ public record OutgoingMessageEntity(UUID guid,
.setServerTimestamp(serverTimestamp())
.setDestinationServiceId(destinationUuid().toServiceIdentifierString())
.setServerGuid(guid().toString())
.setStory(story)
.setUrgent(urgent);
if (story) {
// Avoid sending this field if it's false.
builder.setStory(true);
}
if (sourceUuid() != null) {
builder.setSourceServiceId(sourceUuid().toServiceIdentifierString());
builder.setSourceDevice(sourceDevice());

View File

@@ -168,9 +168,13 @@ public class MessagesAnonymousGrpcService extends SimpleMessagesAnonymousGrpc.Me
.setDestinationServiceId(destinationServiceIdentifier.toServiceIdentifierString())
.setEphemeral(ephemeral)
.setUrgent(urgent)
.setStory(story)
.setContent(entry.getValue().getPayload());
if (story) {
// Avoid sending this field if it's false.
envelopeBuilder.setStory(true);
}
spamCheckResult.token().ifPresent(reportSpamToken ->
envelopeBuilder.setReportSpamToken(ByteString.copyFrom(reportSpamToken)));

View File

@@ -145,15 +145,20 @@ public class MessagesManager {
return insertSharedMultiRecipientMessagePayload(multiRecipientMessage)
.thenCompose(sharedMrmKey -> {
final Envelope prototypeMessage = Envelope.newBuilder()
final Envelope.Builder envelopeBuilder = Envelope.newBuilder()
.setType(Envelope.Type.UNIDENTIFIED_SENDER)
.setClientTimestamp(clientTimestamp == 0 ? serverTimestamp : clientTimestamp)
.setServerTimestamp(serverTimestamp)
.setStory(isStory)
.setEphemeral(isEphemeral)
.setUrgent(isUrgent)
.setSharedMrmKey(ByteString.copyFrom(sharedMrmKey))
.build();
.setSharedMrmKey(ByteString.copyFrom(sharedMrmKey));
if (isStory) {
// Avoid sending this field if it's false.
envelopeBuilder.setStory(true);
}
final Envelope prototypeMessage = envelopeBuilder.build();
final Map<Account, Map<Byte, Boolean>> clientPresenceByAccountAndDevice = new ConcurrentHashMap<>();