Implement sync protocol changes
Update protobuf definitions and refactor message receive and decrypt codepath to support new protocol, including various flavors of sync messages (sent messages, contacts, and groups). Also cleans up background.js and lets libtextsecure internalize textsecure.processDecrypted and ensure that it is called before handing DataMessages off to the application. The Envelope structure now has a generic content field and a legacyMessage field for backwards compatibility. We'll send outgoing messages as legacy messages, and sync messages as "content" while continuing to support both legacy and non-legacy messages on the receive side until old clients have a chance to transition.
This commit is contained in:
parent
757bcd4e50
commit
a833d62a71
13 changed files with 756 additions and 379 deletions
|
@ -22,7 +22,7 @@ describe('Protocol', function() {
|
|||
it('works', function(done) {
|
||||
localStorage.clear();
|
||||
|
||||
var text_message = new textsecure.protobuf.PushMessageContent();
|
||||
var text_message = new textsecure.protobuf.DataMessage();
|
||||
text_message.body = "Hi Mom";
|
||||
var server_message = {
|
||||
type: 4, // unencrypted
|
||||
|
@ -31,8 +31,12 @@ describe('Protocol', function() {
|
|||
message: text_message.encode()
|
||||
};
|
||||
|
||||
return textsecure.protocol_wrapper.handleIncomingPushMessageProto(server_message).
|
||||
then(function(message) {
|
||||
return textsecure.protocol_wrapper.handleEncryptedMessage(
|
||||
server_message.source,
|
||||
server_message.source_device,
|
||||
server_message.type,
|
||||
server_message.message
|
||||
).then(function(message) {
|
||||
assert.equal(message.body, text_message.body);
|
||||
assert.equal(message.attachments.length, text_message.attachments.length);
|
||||
assert.equal(text_message.attachments.length, 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue