# HG changeset patch # User JC Brand # Date 1588158022 -7200 # Node ID d56b3c0195a84106f6d4855abd55ba89d1e36aef # Parent 22784f001b7fad85bfe39536e3d358686438b70a mod_muc_batched_probe: New module diff -r 22784f001b7f -r d56b3c0195a8 mod_muc_batched_probe/README.markdown --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_muc_batched_probe/README.markdown Wed Apr 29 13:00:22 2020 +0200 @@ -0,0 +1,49 @@ +# mod_muc_batched_probe + +This module allows you to probe the presences of multiple MUC occupants or members. + +XEP-0045 makes provision for MUC presence probes, which allows an entity to +probe for the presence information of a MUC occupant (or offline member). + +See here: https://xmpp.org/extensions/xep-0045.html#bizrules-presence + +This module creates the possibility to probe with a single IQ stanza the +presence information of multiple JIDs, instead of having to send out a presence +probe stanza per JID. + +The IQ stanza needs to look as follows: + +``` + + + + + + + + + +``` + + + +## Configuration + +Under your MUC component, add `muc_batched_probe` to `modules_enabled` + +``` + Component "conference.example.org" "muc" + modules_enabled = { + "muc_batched_probe"; + } +``` + + +## Client Support + +Converse.js has a plugin which supports this feature. + +https://www.npmjs.com/package/@converse-plugins/muc-presence-probe diff -r 22784f001b7f -r d56b3c0195a8 mod_muc_batched_probe/mod_muc_batched_probe.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_muc_batched_probe/mod_muc_batched_probe.lua Wed Apr 29 13:00:22 2020 +0200 @@ -0,0 +1,35 @@ +-- This module allows you to probe the MUC presences for multiple occupants. +-- Copyright (C) 2020 JC Brand + +local st = require "util.stanza"; +local mod_muc = module:depends"muc"; +local get_room_from_jid = rawget(mod_muc, "get_room_from_jid") or + function (jid) + local rooms = rawget(mod_muc, "rooms"); + return rooms[jid]; + end + +module:log("debug", "Module loaded"); + + +local function respondToBatchedProbe(event) + local stanza = event.stanza; + if stanza.attr.type ~= "get" then + return; + end + local query = stanza:get_child("query", "http://jabber.org/protocol/muc#user"); + if not query then + return; + end; + + local room = get_room_from_jid(stanza.attr.to); + for item in query.get_children() do + local probed_jid = item.attr.jid; + room:respond_to_probe(stanza.attr.from, probed_jid); + end + event.origin.send(st.reply(stanza)); + return true; +end + + +module:hook("iq/bare", respondToBatchedProbe, 1);