Mercurial > prosody-modules
annotate mod_muc_batched_probe/mod_muc_batched_probe.lua @ 4049:78f1de5301fc
mod_adhoc_dataforms_demo: Fix duplicate field prevention
It's supposed to only include each type of form field once per form at
most but it didn't note which fields it had added already. No idea what
the probability was anyways, probably pretty low.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 23 Jun 2020 19:40:55 +0200 |
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); |