From f6f35c5b6110c3f0f34e4648e2dedac6a52ed2f4 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sat, 26 Jul 2014 01:53:24 -0400 Subject: [PATCH] Fix a missing function and dont blow up on delivery receipts --- js/api.js | 4 ++++ js/crypto.js | 2 ++ js/helpers.js | 5 +++++ protos/IncomingPushMessageSignal.proto | 3 ++- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/js/api.js b/js/api.js index 78f9e721..630585be 100644 --- a/js/api.js +++ b/js/api.js @@ -350,6 +350,10 @@ window.textsecure.api = function() { else console.log("Got invalid message from server: " + message); }; + + socketWrapper.send = function(msg) { + socket.send(msg); + } }; connect(); diff --git a/js/crypto.js b/js/crypto.js index eceabc3d..26440c19 100644 --- a/js/crypto.js +++ b/js/crypto.js @@ -792,6 +792,8 @@ window.textsecure.crypto = function() { throw new Error("Bad version byte"); var from = proto.source + "." + (proto.sourceDevice == null ? 0 : proto.sourceDevice); return handlePreKeyWhisperMessage(from, getString(proto.message)); + case textsecure.protos.IncomingPushMessageProtobuf.Type.RECEIPT: + return Promise.resolve(null); default: return new Promise(function(resolve, reject) { reject(new Error("Unknown message type")); }); } diff --git a/js/helpers.js b/js/helpers.js index 9d5b5770..58879c10 100644 --- a/js/helpers.js +++ b/js/helpers.js @@ -656,6 +656,11 @@ window.textsecure.subscribeToPush = function(message_callback) { console.log("Successfully decoded message with id: " + message.id); socket.send(JSON.stringify({type: 1, id: message.id})); return textsecure.crypto.handleIncomingPushMessageProto(proto).then(function(decrypted) { + // Delivery receipt + if (decrypted === null) + //TODO: Pass to UI + return; + // Now that its decrypted, validate the message and clean it up for consumer processing // Note that messages may (generally) only perform one action and we ignore remaining fields // after the first action. diff --git a/protos/IncomingPushMessageSignal.proto b/protos/IncomingPushMessageSignal.proto index 88ca10b9..88a4c5ed 100644 --- a/protos/IncomingPushMessageSignal.proto +++ b/protos/IncomingPushMessageSignal.proto @@ -10,6 +10,7 @@ message IncomingPushMessageSignal { KEY_EXCHANGE = 2; PREKEY_BUNDLE = 3; PLAINTEXT = 4; + RECEIPT = 5; } optional Type type = 1; optional string source = 2; @@ -49,4 +50,4 @@ message PushMessageContent { repeated AttachmentPointer attachments = 2; optional GroupContext group = 3; optional uint32 flags = 4; -} +} \ No newline at end of file