Tweak replayable errors
1. Return the value returned by the registered function, to expose the underlying promise to the caller. 2. Stop accepting extra arguments to the replay function. The caller should be able to do what they want with the returned promise instead. 3. Add a timestamp argument to the outgoing case, needed to re-try sending a message.
This commit is contained in:
parent
31e7d285e3
commit
e88d4d8170
2 changed files with 12 additions and 14 deletions
|
@ -40,31 +40,30 @@
|
|||
ReplayableError.prototype.constructor = ReplayableError;
|
||||
|
||||
ReplayableError.prototype.replay = function() {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
args.shift();
|
||||
args = this.args.concat(args);
|
||||
|
||||
registeredFunctions[this.functionCode].apply(window, args);
|
||||
return registeredFunctions[this.functionCode].apply(window, this.args);
|
||||
};
|
||||
|
||||
function IncomingIdentityKeyError(number, message) {
|
||||
ReplayableError.call(this, {
|
||||
functionCode : Type.INIT_SESSION,
|
||||
args : [number, message]
|
||||
|
||||
});
|
||||
this.name = 'IncomingIdentityKeyError';
|
||||
this.message = "The identity of the sender has changed. This may be malicious, or the sender may have simply reinstalled TextSecure.";
|
||||
this.number = number.split('.')[0];
|
||||
}
|
||||
IncomingIdentityKeyError.prototype = new ReplayableError();
|
||||
IncomingIdentityKeyError.prototype.constructor = IncomingIdentityKeyError;
|
||||
|
||||
function OutgoingIdentityKeyError(number, message) {
|
||||
function OutgoingIdentityKeyError(number, message, timestamp) {
|
||||
ReplayableError.call(this, {
|
||||
functionCode : Type.SEND_MESSAGE,
|
||||
args : [number, message]
|
||||
args : [number, message, timestamp]
|
||||
});
|
||||
this.name = 'OutgoingIdentityKeyError';
|
||||
this.message = "The identity of the destination has changed. This may be malicious, or the destination may have simply reinstalled TextSecure.";
|
||||
this.number = number.split('.')[0];
|
||||
}
|
||||
OutgoingIdentityKeyError.prototype = new ReplayableError();
|
||||
OutgoingIdentityKeyError.prototype.constructor = OutgoingIdentityKeyError;
|
||||
|
|
|
@ -40,31 +40,30 @@
|
|||
ReplayableError.prototype.constructor = ReplayableError;
|
||||
|
||||
ReplayableError.prototype.replay = function() {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
args.shift();
|
||||
args = this.args.concat(args);
|
||||
|
||||
registeredFunctions[this.functionCode].apply(window, args);
|
||||
return registeredFunctions[this.functionCode].apply(window, this.args);
|
||||
};
|
||||
|
||||
function IncomingIdentityKeyError(number, message) {
|
||||
ReplayableError.call(this, {
|
||||
functionCode : Type.INIT_SESSION,
|
||||
args : [number, message]
|
||||
|
||||
});
|
||||
this.name = 'IncomingIdentityKeyError';
|
||||
this.message = "The identity of the sender has changed. This may be malicious, or the sender may have simply reinstalled TextSecure.";
|
||||
this.number = number.split('.')[0];
|
||||
}
|
||||
IncomingIdentityKeyError.prototype = new ReplayableError();
|
||||
IncomingIdentityKeyError.prototype.constructor = IncomingIdentityKeyError;
|
||||
|
||||
function OutgoingIdentityKeyError(number, message) {
|
||||
function OutgoingIdentityKeyError(number, message, timestamp) {
|
||||
ReplayableError.call(this, {
|
||||
functionCode : Type.SEND_MESSAGE,
|
||||
args : [number, message]
|
||||
args : [number, message, timestamp]
|
||||
});
|
||||
this.name = 'OutgoingIdentityKeyError';
|
||||
this.message = "The identity of the destination has changed. This may be malicious, or the destination may have simply reinstalled TextSecure.";
|
||||
this.number = number.split('.')[0];
|
||||
}
|
||||
OutgoingIdentityKeyError.prototype = new ReplayableError();
|
||||
OutgoingIdentityKeyError.prototype.constructor = OutgoingIdentityKeyError;
|
||||
|
|
Loading…
Reference in a new issue