Software /
code /
prosody-modules
Comparison
mod_admin_blocklist/mod_admin_blocklist.lua @ 4805:683d1ad16b56
mod_admin_blocklist: Update admin check for new 0.12 role API
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 04 Dec 2021 16:17:55 +0100 |
parent | 2313:5d05139d0555 |
child | 5016:964de9997552 |
comparison
equal
deleted
inserted
replaced
4804:a7c0c70e64b6 | 4805:683d1ad16b56 |
---|---|
1 -- mod_admin_blocklist | 1 -- mod_admin_blocklist |
2 -- | 2 -- |
3 -- If a local admin has blocked a domain, don't allow s2s to that domain | 3 -- If a local admin has blocked a domain, don't allow s2s to that domain |
4 -- | 4 -- |
5 -- Copyright (C) 2015 Kim Alvefur | 5 -- Copyright (C) 2015-2021 Kim Alvefur |
6 -- | 6 -- |
7 -- This file is MIT/X11 licensed. | 7 -- This file is MIT/X11 licensed. |
8 -- | 8 -- |
9 | 9 |
10 module:depends("blocklist"); | 10 module:depends("blocklist"); |
11 | 11 |
12 local st = require"util.stanza"; | 12 local st = require"util.stanza"; |
13 local jid_split = require"util.jid".split; | 13 local jid_split = require"util.jid".split; |
14 | 14 |
15 local admins = module:get_option_inherited_set("admins", {}) / | 15 local usermanager = require "core.usermanager"; |
16 | |
17 local admins; | |
18 if usermanager.get_jids_with_role then | |
19 local set = require "util.set"; | |
20 admins = set.new(usermanager.get_jids_with_role("prosody:admin"), module.host); | |
21 else -- COMPAT w/pre-0.12 | |
22 admins = module:get_option_inherited_set("admins", {}); | |
23 end | |
24 admins = admins / | |
16 function (admin) -- Filter out non-local admins | 25 function (admin) -- Filter out non-local admins |
17 local user, host = jid_split(admin); | 26 local user, host = jid_split(admin); |
18 if host == module.host then return user; end | 27 if host == module.host then return user; end |
19 end | 28 end |
20 | 29 |