annotate mod_muc_batched_probe/mod_muc_batched_probe.lua @ 4127:e9e10ec1b91c

mod_firewall: Add checkcerts option for HTTP lists, cert verification disabled when SNI unsupported This provides a balance between security and usability. SNI is supported in Prosody trunk and in Prosody 0.11 from commit 30d3f6f85eb8 (scheduled for 0.11.7).
author Matthew Wild <mwild1@gmail.com>
date Tue, 15 Sep 2020 11:49:55 +0100
parents 845d13ab0dc0
children 4611999fd8d3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4000
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
1 -- This module allows you to probe the MUC presences for multiple occupants.
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
2 -- Copyright (C) 2020 JC Brand
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
3
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
4 local st = require "util.stanza";
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
5 local mod_muc = module:depends"muc";
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
6 local get_room_from_jid = rawget(mod_muc, "get_room_from_jid") or
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
7 function (jid)
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
8 local rooms = rawget(mod_muc, "rooms");
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
9 return rooms[jid];
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
10 end
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
11
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
12 module:log("debug", "Module loaded");
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
13
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
14
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
15 local function respondToBatchedProbe(event)
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
16 local stanza = event.stanza;
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
17 if stanza.attr.type ~= "get" then
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
18 return;
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
19 end
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
20 local query = stanza:get_child("query", "http://jabber.org/protocol/muc#user");
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
21 if not query then
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
22 return;
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
23 end;
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
24
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
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
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
27 local probed_jid = item.attr.jid;
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
28 room:respond_to_probe(stanza.attr.from, probed_jid);
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
29 end
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
30 event.origin.send(st.reply(stanza));
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
31 return true;
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
32 end
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
33
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
34
d56b3c0195a8 mod_muc_batched_probe: New module
JC Brand <jc@opkode.com>
parents:
diff changeset
35 module:hook("iq/bare", respondToBatchedProbe, 1);