|
|
@ -142,6 +142,12 @@
|
|
|
|
return promise.then(function() {
|
|
|
|
return promise.then(function() {
|
|
|
|
this.save({sent: true});
|
|
|
|
this.save({sent: true});
|
|
|
|
}.bind(this)).catch(function(errors) {
|
|
|
|
}.bind(this)).catch(function(errors) {
|
|
|
|
|
|
|
|
this.set({sent: true});
|
|
|
|
|
|
|
|
this.saveErrors(errors);
|
|
|
|
|
|
|
|
}.bind(this));
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
saveErrors: function(errors) {
|
|
|
|
if (!(errors instanceof Array)) {
|
|
|
|
if (!(errors instanceof Array)) {
|
|
|
|
errors = [errors];
|
|
|
|
errors = [errors];
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -149,8 +155,7 @@
|
|
|
|
console.log(e);
|
|
|
|
console.log(e);
|
|
|
|
console.log(e.reason, e.stack);
|
|
|
|
console.log(e.reason, e.stack);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.save({
|
|
|
|
return this.save({
|
|
|
|
sent: true,
|
|
|
|
|
|
|
|
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');
|
|
|
@ -158,7 +163,6 @@
|
|
|
|
return e;
|
|
|
|
return e;
|
|
|
|
})
|
|
|
|
})
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}.bind(this));
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
resolveConflict: function(number) {
|
|
|
|
resolveConflict: function(number) {
|
|
|
@ -166,25 +170,15 @@
|
|
|
|
if (error) {
|
|
|
|
if (error) {
|
|
|
|
var promise = new textsecure.ReplayableError(error).replay();
|
|
|
|
var promise = new textsecure.ReplayableError(error).replay();
|
|
|
|
if (this.isIncoming()) {
|
|
|
|
if (this.isIncoming()) {
|
|
|
|
promise.then(function(dataMessage) {
|
|
|
|
promise = promise.then(function(dataMessage) {
|
|
|
|
this.handleDataMessage(dataMessage);
|
|
|
|
this.handleDataMessage(dataMessage);
|
|
|
|
this.save('errors', []);
|
|
|
|
|
|
|
|
}.bind(this)).catch(function(e) {
|
|
|
|
|
|
|
|
//this.save('errors', [_.pick(e, ['name', 'message'])]);
|
|
|
|
|
|
|
|
var errors = this.get('errors').concat(
|
|
|
|
|
|
|
|
_.pick(e, ['name', 'message'])
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
this.save('errors', errors);
|
|
|
|
|
|
|
|
}.bind(this));
|
|
|
|
}.bind(this));
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
promise.then(function() {
|
|
|
|
promise.then(function() {
|
|
|
|
var errors = _.reject(this.get('errors'), function(e) {
|
|
|
|
this.save('errors', []);
|
|
|
|
return e.name === 'OutgoingIdentityKeyError' &&
|
|
|
|
}.bind(this)).catch(function(e) {
|
|
|
|
e.number === number;
|
|
|
|
this.saveErrors(e);
|
|
|
|
});
|
|
|
|
|
|
|
|
this.save({sent: true, errors: errors});
|
|
|
|
|
|
|
|
}.bind(this));
|
|
|
|
}.bind(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
return promise;
|
|
|
|
return promise;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|