mod_c2s: Do not allow the stream 'to' to change across stream restarts (fixes #1147)
[prosody.git] / plugins / mod_watchregistrations.lua
blob0e9d2fcab566aa2cb0f2dce5b72b05f804ab2a10
1 -- Prosody IM
2 -- Copyright (C) 2008-2010 Matthew Wild
3 -- Copyright (C) 2008-2010 Waqas Hussain
4 --
5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information.
7 --
10 local host = module:get_host();
11 local jid_prep = require "util.jid".prep;
13 local registration_watchers = module:get_option_set("registration_watchers", module:get_option("admins", {})) / jid_prep;
14 local registration_notification = module:get_option("registration_notification", "User $username just registered on $host from $ip");
16 local st = require "util.stanza";
18 module:hook("user-registered", function (user)
19 module:log("debug", "Notifying of new registration");
20 local message = st.message{ type = "chat", from = host }
21 :tag("body")
22 :text(registration_notification:gsub("%$(%w+)", function (v)
23 return user[v] or user.session and user.session[v] or nil;
24 end))
25 :up();
26 for jid in registration_watchers do
27 module:log("debug", "Notifying %s", jid);
28 message.attr.to = jid;
29 module:send(message);
30 end
31 end);