mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 12:19:41 +00:00
Normalize send-path error handling
Receive and handle an array of errors in both the group and individual cases.
This commit is contained in:
@@ -66,14 +66,20 @@
|
||||
else {
|
||||
sendFunc = textsecure.messaging.sendMessageToGroup;
|
||||
}
|
||||
sendFunc(this.get('id'), body, attachments, now).catch(function(e) {
|
||||
if (e.name === 'OutgoingIdentityKeyError') {
|
||||
e.args.push(message.id);
|
||||
message.save({ errors : [e] }).then(function() {
|
||||
sendFunc(this.get('id'), body, attachments, now).catch(function(errors) {
|
||||
var keyErrors = [];
|
||||
_.each(errors, function(e) {
|
||||
if (e.error.name === 'OutgoingIdentityKeyError') {
|
||||
e.error.args.push(message.id);
|
||||
keyErrors.push(e.error);
|
||||
}
|
||||
});
|
||||
if (keyErrors.length) {
|
||||
message.save({ errors : keyErrors }).then(function() {
|
||||
extension.trigger('message', message); // notify frontend listeners
|
||||
});
|
||||
} else {
|
||||
throw e;
|
||||
throw errors;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user