Process end session flags in sync messages

Because remote clients will delete all sessions in response to an end
session message, regardless of which device it came from, when our
linked device sends an end session message, we must also end all
sessions with the destination.

This change moves the end session flag processing to processDecrypted,
which is shared between handlers of sent messages, data messages, and
messages which are re-tried after resolving identity conflicts.

// FREEBIE
This commit is contained in:
lilia 2016-02-04 11:25:25 -08:00
parent fe82e469f2
commit 27fe7e355e
2 changed files with 32 additions and 18 deletions

View file

@ -36947,15 +36947,22 @@ MessageReceiver.prototype.extend({
}.bind(this));
},
handleSentMessage: function(destination, timestamp, message) {
return this.processDecrypted(message, this.number).then(function(message) {
var ev = new Event('sent');
ev.data = {
destination : destination,
timestamp : timestamp.toNumber(),
message : message
};
this.dispatchEvent(ev);
}.bind(this));
var p = Promise.resolve();
if ((message.flags & textsecure.protobuf.DataMessage.Flags.END_SESSION) ==
textsecure.protobuf.DataMessage.Flags.END_SESSION ) {
p = this.handleEndSession(destination);
}
return p.then(function() {
return this.processDecrypted(message, this.number).then(function(message) {
var ev = new Event('sent');
ev.data = {
destination : destination,
timestamp : timestamp.toNumber(),
message : message
};
this.dispatchEvent(ev);
}.bind(this));
});
},
handleDataMessage: function(envelope, message, close_session) {
var encodedNumber = envelope.source + '.' + envelope.sourceDevice;

View file

@ -130,15 +130,22 @@ MessageReceiver.prototype.extend({
}.bind(this));
},
handleSentMessage: function(destination, timestamp, message) {
return this.processDecrypted(message, this.number).then(function(message) {
var ev = new Event('sent');
ev.data = {
destination : destination,
timestamp : timestamp.toNumber(),
message : message
};
this.dispatchEvent(ev);
}.bind(this));
var p = Promise.resolve();
if ((message.flags & textsecure.protobuf.DataMessage.Flags.END_SESSION) ==
textsecure.protobuf.DataMessage.Flags.END_SESSION ) {
p = this.handleEndSession(destination);
}
return p.then(function() {
return this.processDecrypted(message, this.number).then(function(message) {
var ev = new Event('sent');
ev.data = {
destination : destination,
timestamp : timestamp.toNumber(),
message : message
};
this.dispatchEvent(ev);
}.bind(this));
});
},
handleDataMessage: function(envelope, message, close_session) {
var encodedNumber = envelope.source + '.' + envelope.sourceDevice;