Make sure we're connected to MUC before sending status update
This commit is contained in:
parent
c3aafdf341
commit
6ee3ddbc8c
@ -1908,10 +1908,20 @@ const ChatRoomMixin = {
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* When sending a status update presence (i.e. based on the `<show>`
|
||||
* element), we need to first make sure that the MUC is connected,
|
||||
* otherwise we will get an error from the MUC service.
|
||||
* @method _converse.ChatRoom#sendStatusPresence
|
||||
*/
|
||||
async sendStatusPresence (presence) {
|
||||
await this.rejoinIfNecessary();
|
||||
api.send(presence);
|
||||
},
|
||||
|
||||
/**
|
||||
* Check whether we're still joined and re-join if not
|
||||
* @async
|
||||
* @private
|
||||
* @method _converse.ChatRoom#rejoinIfNecessary
|
||||
*/
|
||||
async rejoinIfNecessary () {
|
||||
|
@ -18,28 +18,20 @@ export default {
|
||||
*/
|
||||
async send (type, to, status, child_nodes) {
|
||||
await api.waitUntil('statusInitialized');
|
||||
|
||||
if (child_nodes && !Array.isArray(child_nodes)) {
|
||||
child_nodes = [child_nodes];
|
||||
}
|
||||
const model= _converse.xmppstatus
|
||||
const presence = await model.constructPresence(type, to, status);
|
||||
if (child_nodes) {
|
||||
if (!Array.isArray(child_nodes)) {
|
||||
child_nodes = [child_nodes];
|
||||
}
|
||||
child_nodes.map(c => c?.tree() ?? c).forEach(c => presence.cnode(c).up());
|
||||
}
|
||||
child_nodes?.map(c => c?.tree() ?? c).forEach(c => presence.cnode(c).up());
|
||||
api.send(presence);
|
||||
|
||||
if (['away', 'chat', 'dnd', 'online', 'xa', undefined].includes(type)) {
|
||||
const mucs = await api.rooms.get();
|
||||
mucs.forEach(async muc => {
|
||||
const presence = await model.constructPresence(type, muc.getRoomJIDAndNick(), status);
|
||||
if (child_nodes) {
|
||||
if (!Array.isArray(child_nodes)) {
|
||||
child_nodes = [child_nodes];
|
||||
}
|
||||
child_nodes.map(c => c?.tree() ?? c).forEach(c => presence.cnode(c).up());
|
||||
}
|
||||
api.send(presence);
|
||||
child_nodes?.map(c => c?.tree() ?? c).forEach(c => presence.cnode(c).up());
|
||||
muc.sendStatusPresence(presence);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user