|
@@ -417,7 +417,28 @@ converse.plugins.add('converse-chatboxes', {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
- shouldShowErrorMessage () {
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @private
|
|
|
|
+ * @method _converse.ChatBox#shouldShowErrorMessage
|
|
|
|
+ * @returns {boolean}
|
|
|
|
+ */
|
|
|
|
+ shouldShowErrorMessage (stanza) {
|
|
|
|
+ const id = stanza.getAttribute('id');
|
|
|
|
+ if (id) {
|
|
|
|
+ const msgs = this.messages.where({'msgid': id});
|
|
|
|
+ const referenced_msgs = msgs.filter(m => m.get('type') !== 'error');
|
|
|
|
+ if (!referenced_msgs.length && stanza.querySelector('body') === null) {
|
|
|
|
+ // If the error refers to a message not included in our store,
|
|
|
|
+ // and it doesn't have a <body> tag, we assume that this was a
|
|
|
|
+ // CSI message (which we don't store).
|
|
|
|
+ // See https://github.com/conversejs/converse.js/issues/1317
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ const dupes = msgs.filter(m => m.get('type') === 'error');
|
|
|
|
+ if (dupes.length) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
// Gets overridden in ChatRoom
|
|
// Gets overridden in ChatRoom
|
|
return true;
|
|
return true;
|
|
},
|
|
},
|
|
@@ -988,34 +1009,26 @@ converse.plugins.add('converse-chatboxes', {
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|
|
- async onErrorMessage (message) {
|
|
|
|
- /* Handler method for all incoming error message stanzas
|
|
|
|
- */
|
|
|
|
- const from_jid = Strophe.getBareJidFromJid(message.getAttribute('from'));
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Handler method for all incoming error stanza stanzas.
|
|
|
|
+ * @private
|
|
|
|
+ * @method _converse.ChatBox#onErrorMessage
|
|
|
|
+ * @param { XMLElement } stanza - The error message stanza
|
|
|
|
+ */
|
|
|
|
+ async onErrorMessage (stanza) {
|
|
|
|
+ const from_jid = Strophe.getBareJidFromJid(stanza.getAttribute('from'));
|
|
if (utils.isSameBareJID(from_jid, _converse.bare_jid)) {
|
|
if (utils.isSameBareJID(from_jid, _converse.bare_jid)) {
|
|
- return true;
|
|
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
const chatbox = this.getChatBox(from_jid);
|
|
const chatbox = this.getChatBox(from_jid);
|
|
if (!chatbox) {
|
|
if (!chatbox) {
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- const id = message.getAttribute('id');
|
|
|
|
- if (id) {
|
|
|
|
- const msgs = chatbox.messages.where({'msgid': id});
|
|
|
|
- if (!msgs.length || msgs.filter(m => m.get('type') === 'error').length) {
|
|
|
|
- // If the error refers to a message not included in our store.
|
|
|
|
- // We assume that this was a CSI message (which we don't store).
|
|
|
|
- // See https://github.com/conversejs/converse.js/issues/1317
|
|
|
|
- //
|
|
|
|
- // We also ignore duplicate error messages.
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
- const should_show = await chatbox.shouldShowErrorMessage(message);
|
|
|
|
|
|
+ const should_show = await chatbox.shouldShowErrorMessage(stanza);
|
|
if (!should_show) {
|
|
if (!should_show) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- const attrs = await chatbox.getMessageAttributesFromStanza(message, message);
|
|
|
|
|
|
+ const attrs = await chatbox.getMessageAttributesFromStanza(stanza, stanza);
|
|
chatbox.messages.create(attrs);
|
|
chatbox.messages.create(attrs);
|
|
},
|
|
},
|
|
|
|
|