From fffcba0fec4f4803fd588a58d0301032e9127c94 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Tue, 8 May 2018 16:50:57 -0700 Subject: [PATCH] Properly handle contact property as an array in MessageReceiver --- libtextsecure/message_receiver.js | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js index ae447f83e..c09e23b47 100644 --- a/libtextsecure/message_receiver.js +++ b/libtextsecure/message_receiver.js @@ -1065,12 +1065,26 @@ MessageReceiver.prototype.extend({ promises.push(this.handleAttachment(attachment)); } - if ( - decrypted.contact && - decrypted.contact.avatar && - decrypted.contact.avatar.avatar - ) { - promises.push(this.handleAttachment(decrypted.contact.avatar.avatar)); + if (decrypted.contact && decrypted.contact.length) { + const contacts = decrypted.contact; + + for (let i = 0, max = contacts.length; i < max; i += 1) { + const contact = contacts[i]; + const { avatar } = contact; + + if (avatar && avatar.avatar) { + // We don't want the failure of a thumbnail download to fail the handling of + // this message entirely, like we do for full attachments. + promises.push( + this.handleAttachment(avatar.avatar).catch(error => { + console.log( + 'Problem loading avatar for contact', + error && error.stack ? error.stack : error + ); + }) + ); + } + } } if (decrypted.quote && decrypted.quote.id) {