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
pull/749/head
lilia 9 years ago
parent fe82e469f2
commit 27fe7e355e

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

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

Loading…
Cancel
Save