Software /
code /
prosody-modules
Comparison
mod_muc_local_only/mod_muc_local_only.lua @ 4019:221b6bee26e2
mod_muc_local_only: New module to restrict a list of MUCs to local users
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 13 May 2020 11:43:27 +0100 |
comparison
equal
deleted
inserted
replaced
4018:f27becd421bd | 4019:221b6bee26e2 |
---|---|
1 local jid = require "util.jid"; | |
2 local st = require "util.stanza"; | |
3 | |
4 local local_rooms = module:get_option_inherited_set("muc_local_only", {}); | |
5 | |
6 module:hook("muc-occupant-pre-join", function (event) | |
7 local room = event.room; | |
8 if not local_rooms:contains(room.jid) then | |
9 return; -- Not a protected room, ignore | |
10 end | |
11 local user_jid = event.occupant.bare_jid; | |
12 local user_host = jid.host(user_jid); | |
13 if not prosody.hosts[user_host] then | |
14 local error_reply = st.error_reply(event.stanza, "cancel", "forbidden", "This group is only available to local users", room.jid); | |
15 event.origin.send(error_reply); | |
16 return true; | |
17 end | |
18 room:set_affiliation(true, user_jid, "member", "Granting access to local user"); | |
19 end); |