From 09afbf8b0741c3ae50cd215d1902d567275123e4 Mon Sep 17 00:00:00 2001 From: Guus der Kinderen Date: Thu, 16 Jun 2016 12:10:24 +0200 Subject: [PATCH] 473: Error message processing This is a fix for https://github.com/candy-chat/candy/issues/473 Displaying an error message should not depend on the XMPP error to contain a text element (as such element is optional). --- src/core/event.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/core/event.js b/src/core/event.js index 9486ede1..6bc1ffac 100644 --- a/src/core/event.js +++ b/src/core/event.js @@ -774,11 +774,16 @@ Candy.Core.Event = (function(self, Strophe, $) { message = { from: from, name: Strophe.getNodeFromJid(from), body: msg.children('subject').text(), type: 'subject' }; // Error messsage } else if(msg.attr('type') === 'error') { - var error = msg.children('error'); - if(error.children('text').length > 0) { - roomJid = partnerJid; - roomName = Strophe.getNodeFromJid(roomJid); - message = { from: msg.attr('from'), type: 'info', body: error.children('text').text() }; + var error = msg.children("error"); + roomJid = partnerJid; + roomName = Strophe.getNodeFromJid(roomJid); + message = { + from: msg.attr("from"), + name: "error", + body: error.children()[0].nodeName + }; + if (error.text().trim().length > 0) { + message.body = error.children('text').text(); } // Chat message } else if(msg.children('body').length > 0) {