Send presence status change to all connected MUCs

Fixes #2725
This commit is contained in:
JC Brand 2021-11-19 14:34:24 +01:00
parent 35947e3d62
commit ed63902ac1
2 changed files with 18 additions and 1 deletions

View File

@ -12,6 +12,7 @@
- #1419: Clicking on avatar should show bigger version
- #2647: Singleton mode doesn't work
- #2704: Send button doesn't work in a multi-user chat
- #2725: Send new presence status to all connected MUCs
- Emit a `change` event when a configuration setting changes
- 3 New configuration settings:

View File

@ -18,7 +18,9 @@ export default {
*/
async send (type, to, status, child_nodes) {
await api.waitUntil('statusInitialized');
const presence = await _converse.xmppstatus.constructPresence(type, to, status);
const model= _converse.xmppstatus
const presence = await model.constructPresence(type, to, status);
if (child_nodes) {
if (!Array.isArray(child_nodes)) {
child_nodes = [child_nodes];
@ -26,6 +28,20 @@ export default {
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);
});
}
}
},