closeSession
This commit is contained in:
parent
12e6b11962
commit
c953c6c16d
2 changed files with 25 additions and 2 deletions
12
js/crypto.js
12
js/crypto.js
|
@ -401,6 +401,15 @@ window.textsecure.crypto = function() {
|
||||||
session.indexInfo.closed = new Date().getTime();
|
session.indexInfo.closed = new Date().getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.closeOpenSessionForDevice = function(encodedNumber) {
|
||||||
|
var session = crypto_storage.getOpenSession(encodedNumber);
|
||||||
|
if (session === undefined)
|
||||||
|
return;
|
||||||
|
|
||||||
|
closeSession(session);
|
||||||
|
crypto_storage.saveSession(encodedNumber, session);
|
||||||
|
}
|
||||||
|
|
||||||
var initSessionFromPreKeyWhisperMessage;
|
var initSessionFromPreKeyWhisperMessage;
|
||||||
var decryptWhisperMessage;
|
var decryptWhisperMessage;
|
||||||
var handlePreKeyWhisperMessage = function(from, encodedMessage) {
|
var handlePreKeyWhisperMessage = function(from, encodedMessage) {
|
||||||
|
@ -570,7 +579,8 @@ window.textsecure.crypto = function() {
|
||||||
|
|
||||||
var finalMessage = textsecure.protos.decodePushMessageContentProtobuf(getString(plaintext));
|
var finalMessage = textsecure.protos.decodePushMessageContentProtobuf(getString(plaintext));
|
||||||
|
|
||||||
if ((finalMessage.flags & 1) == 1) // END_SESSION
|
if ((finalMessage.flags & textsecure.protos.PushMessageContentProtobuf.Flags.END_SESSION)
|
||||||
|
== textsecure.protos.PushMessageContentProtobuf.Flags.END_SESSION)
|
||||||
closeSession(session);
|
closeSession(session);
|
||||||
|
|
||||||
crypto_storage.saveSession(encodedNumber, session, registrationId);
|
crypto_storage.saveSession(encodedNumber, session, registrationId);
|
||||||
|
|
|
@ -209,7 +209,20 @@ window.textsecure.messaging = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.closeSession = function(number) {
|
self.closeSession = function(number) {
|
||||||
//TODO
|
var devices = textsecure.storage.devices.getDeviceObjectsForNumber(number);
|
||||||
|
for (i in devices)
|
||||||
|
textsecure.crypto.closeOpenSessionForDevice(devices[i].encodedNumber);
|
||||||
|
|
||||||
|
return new Promise(function(resolve, reject) {
|
||||||
|
var proto = new textsecure.protos.PushMessageContentProtobuf();
|
||||||
|
proto.flags = textsecure.protos.PushMessageContentProtobuf.Flags.END_SESSION;
|
||||||
|
sendMessageProto([number], proto, function(res) {
|
||||||
|
if (res.failure.length > 0)
|
||||||
|
reject(res.failure[0].error);
|
||||||
|
else
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
|
Loading…
Reference in a new issue