Don't send read syncs or read receipts for messages with errors (#1596)

This commit is contained in:
Scott Nonnenberg 2017-10-23 16:16:01 -07:00 committed by GitHub
parent 632c8c063c
commit 5c8a0d4836

View file

@ -786,7 +786,8 @@
promises.push(m.markRead()); promises.push(m.markRead());
return { return {
sender : m.get('source'), sender : m.get('source'),
timestamp : m.get('sent_at') timestamp : m.get('sent_at'),
hasErrors : Boolean(m.get('errors'))
}; };
}.bind(this)); }.bind(this));
@ -804,6 +805,15 @@
}.bind(this)); }.bind(this));
promises.push(promise); promises.push(promise);
// If a message has errors, we don't want to send anything out about it.
// read syncs - let's wait for a client that really understands the message
// to mark it read. we'll mark our local error read locally, though.
// read receipts - here we can run into infinite loops, where each time the
// conversation is viewed, another error message shows up for the contact
read = read.filter(function(item) {
return !item.hasErrors;
});
if (read.length && options.sendReadReceipts) { if (read.length && options.sendReadReceipts) {
console.log('Sending', read.length, 'read receipts'); console.log('Sending', read.length, 'read receipts');
promises.push(textsecure.messaging.syncReadMessages(read)); promises.push(textsecure.messaging.syncReadMessages(read));