MUC: wait for messages collection to be initialized

before processing MUC messages received prematurely due to SMACKS
resumption.
This commit is contained in:
JC Brand 2020-02-19 14:18:52 +01:00
parent bc48e413f1
commit 58f6d36564

View File

@ -2403,9 +2403,13 @@ converse.plugins.add('converse-muc', {
const muc_jid = Strophe.getBareJidFromJid(stanza.getAttribute('from')); const muc_jid = Strophe.getBareJidFromJid(stanza.getAttribute('from'));
if (!_converse.chatboxes.get(muc_jid)) { if (!_converse.chatboxes.get(muc_jid)) {
_converse.api.waitUntil('chatBoxesFetched') _converse.api.waitUntil('chatBoxesFetched')
.then(() => { .then(async () => {
const muc = _converse.chatboxes.get(muc_jid); 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; return true;