From 5c8a0d4836481d8c381fabbb0bd4d4acf73d26b5 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Mon, 23 Oct 2017 16:16:01 -0700 Subject: [PATCH] Don't send read syncs or read receipts for messages with errors (#1596) --- js/models/conversations.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/js/models/conversations.js b/js/models/conversations.js index a1dc803a7..bb4cdcca3 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -786,7 +786,8 @@ promises.push(m.markRead()); return { sender : m.get('source'), - timestamp : m.get('sent_at') + timestamp : m.get('sent_at'), + hasErrors : Boolean(m.get('errors')) }; }.bind(this)); @@ -804,6 +805,15 @@ }.bind(this)); 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) { console.log('Sending', read.length, 'read receipts'); promises.push(textsecure.messaging.syncReadMessages(read));