Skip to content

Commit

Permalink
Fix #313: Drop messages without a body element.
Browse files Browse the repository at this point in the history
Message stanzas may convey only meta-data and not be intended
for direct display (such as XEP-0085 chat status notifications).
Cadence shouldn't render these as blank messages.
  • Loading branch information
cburschka committed Dec 29, 2015
1 parent 441f09d commit b59e843
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion js/core/xmpp.js
Original file line number Diff line number Diff line change
Expand Up @@ -917,8 +917,11 @@ var xmpp = {
if (type == 'error')
return this.eventMessageError(stanza, node, domain, resource) || true;

// If there is no <body> element, drop the message. (@TODO #201 XEP-0085)
if (!$(stanza).children('body').length) return true;

var body = $('html body p', stanza).contents();
if (!body.length) body = $('body:first', stanza).contents();
if (!body.length) body = $(stanza).children('body').contents();

var delay = $('delay', stanza);
var time = delay.attr('stamp') || (new Date()).toISOString();
Expand Down

0 comments on commit b59e843

Please sign in to comment.