From 4842ef61530af3de518ee49ceab4d1a08bf15a40 Mon Sep 17 00:00:00 2001 From: lilia <liliakai@gmail.com> Date: Wed, 3 Feb 2016 18:18:42 -0800 Subject: [PATCH] Sync end session messages // FREEBIE --- js/libtextsecure.js | 20 +++++++++++--------- libtextsecure/sendmessage.js | 20 +++++++++++--------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/js/libtextsecure.js b/js/libtextsecure.js index 2613b635219..68797e67b3e 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -39263,17 +39263,19 @@ MessageSender.prototype = { proto.body = "TERMINATE"; proto.flags = textsecure.protobuf.DataMessage.Flags.END_SESSION; return this.sendIndividualProto(number, proto, timestamp).then(function(res) { - return textsecure.storage.protocol.getDeviceIds(number).then(function(deviceIds) { - return Promise.all(deviceIds.map(function(deviceId) { - var address = new libsignal.SignalProtocolAddress(number, deviceId); - console.log('closing session for', address.toString()); - var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address); - return sessionCipher.closeOpenSessionForDevice(); - })).then(function() { - return res; + return this.sendSyncMessage(proto.toArrayBuffer(), timestamp, number).then(function() { + return textsecure.storage.protocol.getDeviceIds(number).then(function(deviceIds) { + return Promise.all(deviceIds.map(function(deviceId) { + var address = new libsignal.SignalProtocolAddress(number, deviceId); + console.log('closing session for', address.toString()); + var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address); + return sessionCipher.closeOpenSessionForDevice(); + })).then(function() { + return res; + }); }); }); - }); + }.bind(this)); }, sendMessageToGroup: function(groupId, messageText, attachments, timestamp, expireTimer) { diff --git a/libtextsecure/sendmessage.js b/libtextsecure/sendmessage.js index 9e85c9ba0e4..48af7c7e8a1 100644 --- a/libtextsecure/sendmessage.js +++ b/libtextsecure/sendmessage.js @@ -338,17 +338,19 @@ MessageSender.prototype = { proto.body = "TERMINATE"; proto.flags = textsecure.protobuf.DataMessage.Flags.END_SESSION; return this.sendIndividualProto(number, proto, timestamp).then(function(res) { - return textsecure.storage.protocol.getDeviceIds(number).then(function(deviceIds) { - return Promise.all(deviceIds.map(function(deviceId) { - var address = new libsignal.SignalProtocolAddress(number, deviceId); - console.log('closing session for', address.toString()); - var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address); - return sessionCipher.closeOpenSessionForDevice(); - })).then(function() { - return res; + return this.sendSyncMessage(proto.toArrayBuffer(), timestamp, number).then(function() { + return textsecure.storage.protocol.getDeviceIds(number).then(function(deviceIds) { + return Promise.all(deviceIds.map(function(deviceId) { + var address = new libsignal.SignalProtocolAddress(number, deviceId); + console.log('closing session for', address.toString()); + var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address); + return sessionCipher.closeOpenSessionForDevice(); + })).then(function() { + return res; + }); }); }); - }); + }.bind(this)); }, sendMessageToGroup: function(groupId, messageText, attachments, timestamp, expireTimer) {