2 -- Copyright (C) 2008-2009 Matthew Wild
3 -- Copyright (C) 2008-2009 Waqas Hussain
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
10 local host = module:get_host();
12 local config = require "core.configmanager";
14 local registration_watchers = config.get(host, "core", "registration_watchers")
15 or config.get(host, "core", "admins") or {};
17 local registration_alert = config.get(host, "core", "registration_notification") or "User $username just registered on $host from $ip";
19 local st = require "util.stanza";
21 module:hook("user-registered",
23 module:log("debug", "Notifying of new registration");
24 local message = st.message{ type = "chat", from = host }
26 :text(registration_alert:gsub("%$(%w+)",
27 function (v) return user[v] or user.session and user.session[v] or nil; end));
29 for _, jid in ipairs(registration_watchers) do
30 module:log("debug", "Notifying %s", jid);
31 message.attr.to = jid;
32 core_route_stanza(hosts[host], message);