Skip to content

Commit

Permalink
Send increased protocol version number if CDN key or attachment are u…
Browse files Browse the repository at this point in the history
…sed.
  • Loading branch information
ehrenkret-signal authored and greyson-signal committed Apr 21, 2020
1 parent 4281286 commit 3c6a7b7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
import org.whispersystems.signalservice.api.crypto.UnidentifiedAccess;
import org.whispersystems.signalservice.api.crypto.UnidentifiedAccessPair;
import org.whispersystems.signalservice.api.crypto.UntrustedIdentityException;
import org.whispersystems.signalservice.api.groupsv2.ClientZkOperations;
import org.whispersystems.signalservice.api.messages.SendMessageResult;
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentRemoteId;
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentPointer;
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentRemoteId;
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentStream;
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
import org.whispersystems.signalservice.api.messages.SignalServiceGroup;
Expand Down Expand Up @@ -503,6 +502,13 @@ private byte[] createMessageContent(SignalServiceDataMessage message) throws IOE

if (!pointers.isEmpty()) {
builder.addAllAttachments(pointers);

for (AttachmentPointer pointer : pointers) {
if (pointer.getAttachmentIdentifierCase() == AttachmentPointer.AttachmentIdentifierCase.CDNKEY || pointer.getCdnNumber() != 0) {
builder.setRequiredProtocolVersion(Math.max(DataMessage.ProtocolVersion.CDN_SELECTOR_ATTACHMENTS_VALUE, builder.getRequiredProtocolVersion()));
break;
}
}
}

if (message.getBody().isPresent()) {
Expand Down
13 changes: 7 additions & 6 deletions libsignal/service/src/main/proto/SignalService.proto
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,13 @@ message DataMessage {
enum ProtocolVersion {
option allow_alias = true;

INITIAL = 0;
MESSAGE_TIMERS = 1;
VIEW_ONCE = 2;
VIEW_ONCE_VIDEO = 3;
REACTIONS = 4;
CURRENT = 4;
INITIAL = 0;
MESSAGE_TIMERS = 1;
VIEW_ONCE = 2;
VIEW_ONCE_VIDEO = 3;
REACTIONS = 4;
CDN_SELECTOR_ATTACHMENTS = 5;
CURRENT = 5;
}

optional string body = 1;
Expand Down

0 comments on commit 3c6a7b7

Please sign in to comment.