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:
@@ -40,31 +40,30 @@
|
|||||||
ReplayableError.prototype.constructor = ReplayableError;
|
ReplayableError.prototype.constructor = ReplayableError;
|
||||||
|
|
||||||
ReplayableError.prototype.replay = function() {
|
ReplayableError.prototype.replay = function() {
|
||||||
var args = Array.prototype.slice.call(arguments);
|
return registeredFunctions[this.functionCode].apply(window, this.args);
|
||||||
args.shift();
|
|
||||||
args = this.args.concat(args);
|
|
||||||
|
|
||||||
registeredFunctions[this.functionCode].apply(window, args);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function IncomingIdentityKeyError(number, message) {
|
function IncomingIdentityKeyError(number, message) {
|
||||||
ReplayableError.call(this, {
|
ReplayableError.call(this, {
|
||||||
functionCode : Type.INIT_SESSION,
|
functionCode : Type.INIT_SESSION,
|
||||||
args : [number, message]
|
args : [number, message]
|
||||||
|
|
||||||
});
|
});
|
||||||
this.name = 'IncomingIdentityKeyError';
|
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.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 = new ReplayableError();
|
||||||
IncomingIdentityKeyError.prototype.constructor = IncomingIdentityKeyError;
|
IncomingIdentityKeyError.prototype.constructor = IncomingIdentityKeyError;
|
||||||
|
|
||||||
function OutgoingIdentityKeyError(number, message) {
|
function OutgoingIdentityKeyError(number, message, timestamp) {
|
||||||
ReplayableError.call(this, {
|
ReplayableError.call(this, {
|
||||||
functionCode : Type.SEND_MESSAGE,
|
functionCode : Type.SEND_MESSAGE,
|
||||||
args : [number, message]
|
args : [number, message, timestamp]
|
||||||
});
|
});
|
||||||
this.name = 'OutgoingIdentityKeyError';
|
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.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 = new ReplayableError();
|
||||||
OutgoingIdentityKeyError.prototype.constructor = OutgoingIdentityKeyError;
|
OutgoingIdentityKeyError.prototype.constructor = OutgoingIdentityKeyError;
|
||||||
|
@@ -40,31 +40,30 @@
|
|||||||
ReplayableError.prototype.constructor = ReplayableError;
|
ReplayableError.prototype.constructor = ReplayableError;
|
||||||
|
|
||||||
ReplayableError.prototype.replay = function() {
|
ReplayableError.prototype.replay = function() {
|
||||||
var args = Array.prototype.slice.call(arguments);
|
return registeredFunctions[this.functionCode].apply(window, this.args);
|
||||||
args.shift();
|
|
||||||
args = this.args.concat(args);
|
|
||||||
|
|
||||||
registeredFunctions[this.functionCode].apply(window, args);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function IncomingIdentityKeyError(number, message) {
|
function IncomingIdentityKeyError(number, message) {
|
||||||
ReplayableError.call(this, {
|
ReplayableError.call(this, {
|
||||||
functionCode : Type.INIT_SESSION,
|
functionCode : Type.INIT_SESSION,
|
||||||
args : [number, message]
|
args : [number, message]
|
||||||
|
|
||||||
});
|
});
|
||||||
this.name = 'IncomingIdentityKeyError';
|
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.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 = new ReplayableError();
|
||||||
IncomingIdentityKeyError.prototype.constructor = IncomingIdentityKeyError;
|
IncomingIdentityKeyError.prototype.constructor = IncomingIdentityKeyError;
|
||||||
|
|
||||||
function OutgoingIdentityKeyError(number, message) {
|
function OutgoingIdentityKeyError(number, message, timestamp) {
|
||||||
ReplayableError.call(this, {
|
ReplayableError.call(this, {
|
||||||
functionCode : Type.SEND_MESSAGE,
|
functionCode : Type.SEND_MESSAGE,
|
||||||
args : [number, message]
|
args : [number, message, timestamp]
|
||||||
});
|
});
|
||||||
this.name = 'OutgoingIdentityKeyError';
|
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.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 = new ReplayableError();
|
||||||
OutgoingIdentityKeyError.prototype.constructor = OutgoingIdentityKeyError;
|
OutgoingIdentityKeyError.prototype.constructor = OutgoingIdentityKeyError;
|
||||||
|
Reference in New Issue
Block a user