Stop processing message when it is empty

pull/1127/head
Mikunj 5 years ago
parent 040a8cb225
commit 13832f83bb

@ -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) {

Loading…
Cancel
Save