Fix a missing function and dont blow up on delivery receipts

This commit is contained in:
Matt Corallo 2014-07-26 01:53:24 -04:00
parent d9f53d4c01
commit f6f35c5b61
4 changed files with 13 additions and 1 deletions

View File

@ -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();

View File

@ -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")); });
}

View File

@ -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.

View File

@ -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;
}
}