diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js index 94b14fc7b..86806920f 100644 --- a/libtextsecure/message_receiver.js +++ b/libtextsecure/message_receiver.js @@ -1250,6 +1250,15 @@ MessageReceiver.prototype.extend({ return this.removeFromCache(envelope); } + if (!friendRequest && this.isMessageEmpty(message)) { + window.log.warn( + `Message ${this.getEnvelopeId( + envelope + )} ignored; it was empty` + ); + return this.removeFromCache(envelope); + } + const ev = new Event('message'); ev.confirm = this.removeFromCache.bind(this, envelope); ev.data = { @@ -1265,6 +1274,9 @@ MessageReceiver.prototype.extend({ }) ); }, + isMessageEmpty({ body, attachments, group, flags, quote, contact, preview, groupInvitation }) { + return !flags && _.isEmpty(body) && _.isEmpty(attachments) && _.isEmpty(group) && _.isEmpty(quote) && _.isEmpty(contact) && _.isEmpty(preview) && _.isEmpty(groupInvitation) + }, handleLegacyMessage(envelope) { return this.decrypt(envelope, envelope.legacyMessage).then(plaintext => { if (!plaintext) {