diff --git a/libtextsecure/outgoing_message.js b/libtextsecure/outgoing_message.js index 39fbfab87..8fa8aab9e 100644 --- a/libtextsecure/outgoing_message.js +++ b/libtextsecure/outgoing_message.js @@ -43,9 +43,10 @@ function OutgoingMessage( this.failoverNumbers = []; this.unidentifiedDeliveries = []; - const { numberInfo, senderCertificate } = options; + const { numberInfo, senderCertificate, preKeyBundleType } = options; this.numberInfo = numberInfo; this.senderCertificate = senderCertificate; + this.preKeyBundleType = preKeyBundleType || textsecure.protobuf.PreKeyBundleMessage.Type.UNKOWN; } OutgoingMessage.prototype = { @@ -290,6 +291,12 @@ OutgoingMessage.prototype = { if (this.attachPrekeys) { // Encrypt them with the fallback const preKeyBundleMessage = await libloki.getPreKeyBundleForNumber(number); + preKeyBundleMessage.type = this.preKeyBundleType; + + // If we have to use fallback encryption then this must be a friend request + if (this.fallBackEncryption) + preKeyBundleMessage.type = textsecure.protobuf.PreKeyBundleMessage.Type.FRIEND_REQUEST; + const textBundle = this.convertMessageToText(preKeyBundleMessage); const encryptedBundle = await fallBackEncryption.encrypt(textBundle); preKeys = { preKeyBundleMessage: encryptedBundle.body }; diff --git a/protos/SignalService.proto b/protos/SignalService.proto index e0de8f732..4a9faa797 100644 --- a/protos/SignalService.proto +++ b/protos/SignalService.proto @@ -37,6 +37,13 @@ message Content { } message PreKeyBundleMessage { + enum Type { + UNKNOWN = 0; + FRIEND_REQUEST = 1; + FRIEND_REQUEST_ACCEPT = 2; + RESET_SESSION = 3; + RESET_SESSION_ACK = 4; + } optional bytes identityKey = 1; optional uint32 deviceId = 2; optional uint32 preKeyId = 3; @@ -44,6 +51,7 @@ message PreKeyBundleMessage { optional bytes preKey = 5; optional bytes signedKey = 6; optional bytes signature = 7; + optional Type type = 8; } message CallMessage {