equal
deleted
inserted
replaced
|
1 local it = require "util.iterators"; |
|
2 local jid = require "util.jid"; |
|
3 local set = require "util.set"; |
|
4 local st = require "util.stanza"; |
|
5 |
|
6 local roles_store = module:open_store("roles", "map"); |
|
7 local config_admins = module:get_option_inherited_set("admins") / jid.prep; |
|
8 |
|
9 local function append_host(username) |
|
10 return username.."@"..module.host; |
|
11 end |
|
12 |
|
13 local function get_admins() |
|
14 local role_admins = roles_store:get_all("prosody:admin") or {}; |
|
15 local admins = config_admins + (set.new(it.to_array(it.keys(role_admins))) / append_host); |
|
16 return admins; |
|
17 end |
|
18 |
|
19 function notify(text) --luacheck: ignore 131/notify |
|
20 local base_msg = st.message({ from = module.host }) |
|
21 :text_tag("body", text); |
|
22 for admin_jid in get_admins() do |
|
23 local msg = st.clone(base_msg); |
|
24 msg.attr.to = admin_jid; |
|
25 module:send(msg); |
|
26 end |
|
27 end |