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);
|
||||||
console.log(e.reason, e.stack);
|
console.log(e.reason, e.stack);
|
||||||
});
|
});
|
||||||
return this.save({
|
errors = errors.map(function(e) {
|
||||||
errors : errors.map(function(e) {
|
|
||||||
if (e.constructor === Error) {
|
if (e.constructor === Error) {
|
||||||
return _.pick(e, 'name', 'message', 'code', 'number', 'reason');
|
return _.pick(e, 'name', 'message', 'code', 'number', 'reason');
|
||||||
}
|
}
|
||||||
return e;
|
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) {
|
resend: function(number) {
|
||||||
|
@ -176,17 +184,21 @@
|
||||||
resolveConflict: function(number) {
|
resolveConflict: function(number) {
|
||||||
var error = this.getKeyConflict(number);
|
var error = this.getKeyConflict(number);
|
||||||
if (error) {
|
if (error) {
|
||||||
|
this.removeConflictFor(number);
|
||||||
var promise = new textsecure.ReplayableError(error).replay();
|
var promise = new textsecure.ReplayableError(error).replay();
|
||||||
if (this.isIncoming()) {
|
if (this.isIncoming()) {
|
||||||
promise = promise.then(function(dataMessage) {
|
promise = promise.then(function(dataMessage) {
|
||||||
this.handleDataMessage(dataMessage);
|
this.handleDataMessage(dataMessage);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
} else {
|
||||||
|
promise = promise.then(function() {
|
||||||
|
this.save();
|
||||||
|
}.bind(this));
|
||||||
}
|
}
|
||||||
promise.then(function() {
|
promise.catch(function(e) {
|
||||||
this.save('errors', []);
|
|
||||||
}.bind(this)).catch(function(e) {
|
|
||||||
this.saveErrors(e);
|
this.saveErrors(e);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue