author | JC Brand <jc@opkode.com> |
Fri, 01 May 2020 11:34:09 +0200 | |
changeset 4011 | 845d13ab0dc0 |
parent 4004 | d56b3c0195a8 |
child 4192 | 4611999fd8d3 |
permissions | -rw-r--r-- |
4004 | 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); |
|
4011
845d13ab0dc0
mod_muc_batched_probe: Call instance method
JC Brand <jc@opkode.com>
parents:
4004
diff
changeset
|
26 |
for item in query:children() do |
4004 | 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); |