Mercurial > prosody-modules
comparison mod_admin_blocklist/mod_admin_blocklist.lua @ 5017:96e83b4a93f7
mod_admin_blocklist: Add config option for which role(s) to consider (0.12+)
Fixes that in trunk, a "prosody:operator" (formerly a global admin) is
not considered a "prosody:admin", so those were not included in the set.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 27 Aug 2022 16:36:22 +0200 |
parents | 964de9997552 |
children |
comparison
equal
deleted
inserted
replaced
5016:964de9997552 | 5017:96e83b4a93f7 |
---|---|
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-2021 Kim Alvefur | 5 -- Copyright (C) 2015-2022 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"); |
15 local usermanager = require "core.usermanager"; | 15 local usermanager = require "core.usermanager"; |
16 | 16 |
17 local admins; | 17 local admins; |
18 if usermanager.get_jids_with_role then | 18 if usermanager.get_jids_with_role then |
19 local set = require "util.set"; | 19 local set = require "util.set"; |
20 admins = set.new(usermanager.get_jids_with_role("prosody:admin", module.host)); | 20 local include_roles = module:get_option_set("admin_blocklist_roles", { "prosody:operator"; "prosody:admin" }); |
21 | |
22 admins = set.new(); | |
23 for role in include_roles do | |
24 admins:include(set.new(usermanager.get_jids_with_role(role, module.host))); | |
25 end | |
21 else -- COMPAT w/pre-0.12 | 26 else -- COMPAT w/pre-0.12 |
22 admins = module:get_option_inherited_set("admins", {}); | 27 admins = module:get_option_inherited_set("admins", {}); |
23 end | 28 end |
24 admins = admins / | 29 admins = admins / |
25 function (admin) -- Filter out non-local admins | 30 function (admin) -- Filter out non-local admins |