2 -- Copyright (C) 2008-2010 Matthew Wild
3 -- Copyright (C) 2008-2010 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 registration_watchers = module:get_option("registration_watchers")
13 or module:get_option("admins") or {};
15 local registration_alert = module:get_option("registration_notification") or "User $username just registered on $host from $ip";
17 local st = require "util.stanza";
19 module:hook("user-registered",
21 module:log("debug", "Notifying of new registration");
22 local message = st.message{ type = "chat", from = host }
24 :text(registration_alert:gsub("%$(%w+)",
25 function (v) return user[v] or user.session and user.session[v] or nil; end));
27 for _, jid in ipairs(registration_watchers) do
28 module:log("debug", "Notifying %s", jid);
29 message.attr.to = jid;
30 core_route_stanza(hosts[host], message);