Mercurial > prosody-modules
annotate mod_muc_batched_probe/mod_muc_batched_probe.lua @ 4132:36795f773faf
mod_invites_page: Apply fixes from invite page to client URI page
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 15 Sep 2020 16:15:51 +0100 |
parents | 845d13ab0dc0 |
children | 4611999fd8d3 |
rev | line source |
---|---|
4000 | 1 -- This module allows you to probe the MUC presences for multiple occupants. |
2 -- Copyright (C) 2020 JC Brand | |
3 | |
4 local st = require "util.stanza"; | |
5 local mod_muc = module:depends"muc"; | |
6 local get_room_from_jid = rawget(mod_muc, "get_room_from_jid") or | |
7 function (jid) | |
8 local rooms = rawget(mod_muc, "rooms"); | |
9 return rooms[jid]; | |
10 end | |
11 | |
12 module:log("debug", "Module loaded"); | |
13 | |
14 | |
15 local function respondToBatchedProbe(event) | |
16 local stanza = event.stanza; | |
17 if stanza.attr.type ~= "get" then | |
18 return; | |
19 end | |
20 local query = stanza:get_child("query", "http://jabber.org/protocol/muc#user"); | |
21 if not query then | |
22 return; | |
23 end; | |
24 | |
25 local room = get_room_from_jid(stanza.attr.to); | |
4007
845d13ab0dc0
mod_muc_batched_probe: Call instance method
JC Brand <jc@opkode.com>
parents:
4000
diff
changeset
|
26 for item in query:children() do |
4000 | 27 local probed_jid = item.attr.jid; |
28 room:respond_to_probe(stanza.attr.from, probed_jid); | |
29 end | |
30 event.origin.send(st.reply(stanza)); | |
31 return true; | |
32 end | |
33 | |
34 | |
35 module:hook("iq/bare", respondToBatchedProbe, 1); |