From 58f6d365643fca4de63eeaf00e488f6a98467328 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Wed, 19 Feb 2020 14:18:52 +0100 Subject: [PATCH] MUC: wait for messages collection to be initialized before processing MUC messages received prematurely due to SMACKS resumption. --- src/headless/converse-muc.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/headless/converse-muc.js b/src/headless/converse-muc.js index f7746ae68..f36e44a5f 100644 --- a/src/headless/converse-muc.js +++ b/src/headless/converse-muc.js @@ -2403,9 +2403,13 @@ converse.plugins.add('converse-muc', { const muc_jid = Strophe.getBareJidFromJid(stanza.getAttribute('from')); if (!_converse.chatboxes.get(muc_jid)) { _converse.api.waitUntil('chatBoxesFetched') - .then(() => { + .then(async () => { const muc = _converse.chatboxes.get(muc_jid); - muc && muc.message_handler.run(stanza); + if (muc) { + await muc.initialized; + await muc.messages.fetched + muc.message_handler.run(stanza); + } }); } return true;