Skip to content

Commit

Permalink
Sync end session messages
Browse files Browse the repository at this point in the history
// FREEBIE
  • Loading branch information
liliakai committed May 16, 2017
1 parent cfe0c77 commit 4842ef6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
20 changes: 11 additions & 9 deletions js/libtextsecure.js
Expand Up @@ -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) {
Expand Down
20 changes: 11 additions & 9 deletions libtextsecure/sendmessage.js
Expand Up @@ -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) {
Expand Down

0 comments on commit 4842ef6

Please sign in to comment.