Fix up post-conflict resolution error processing
// FREEBIE
This commit is contained in:
parent
d3812869d2
commit
ae25d62ef2
1 changed files with 22 additions and 10 deletions
|
@ -155,14 +155,22 @@
|
|||
console.log(e);
|
||||
console.log(e.reason, e.stack);
|
||||
});
|
||||
return this.save({
|
||||
errors : errors.map(function(e) {
|
||||
if (e.constructor === Error) {
|
||||
return _.pick(e, 'name', 'message', 'code', 'number', 'reason');
|
||||
}
|
||||
return e;
|
||||
})
|
||||
errors = errors.map(function(e) {
|
||||
if (e.constructor === Error) {
|
||||
return _.pick(e, 'name', 'message', 'code', 'number', 'reason');
|
||||
}
|
||||
return e;
|
||||
});
|
||||
return this.save({errors : this.get('errors').concat(errors)});
|
||||
},
|
||||
|
||||
removeConflictFor: function(number) {
|
||||
var errors = _.reject(this.get('errors'), function(e) {
|
||||
return e.number === number &&
|
||||
(e.name === 'IncomingIdentityKeyError' ||
|
||||
e.name === 'OutgoingIdentityKeyError');
|
||||
});
|
||||
this.set({errors: errors});
|
||||
},
|
||||
|
||||
resend: function(number) {
|
||||
|
@ -176,17 +184,21 @@
|
|||
resolveConflict: function(number) {
|
||||
var error = this.getKeyConflict(number);
|
||||
if (error) {
|
||||
this.removeConflictFor(number);
|
||||
var promise = new textsecure.ReplayableError(error).replay();
|
||||
if (this.isIncoming()) {
|
||||
promise = promise.then(function(dataMessage) {
|
||||
this.handleDataMessage(dataMessage);
|
||||
}.bind(this));
|
||||
} else {
|
||||
promise = promise.then(function() {
|
||||
this.save();
|
||||
}.bind(this));
|
||||
}
|
||||
promise.then(function() {
|
||||
this.save('errors', []);
|
||||
}.bind(this)).catch(function(e) {
|
||||
promise.catch(function(e) {
|
||||
this.saveErrors(e);
|
||||
}.bind(this));
|
||||
|
||||
return promise;
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue