diff options
author | Badlop <badlop@process-one.net> | 2009-11-17 11:14:31 +0000 |
---|---|---|
committer | Badlop <badlop@process-one.net> | 2009-11-17 11:14:31 +0000 |
commit | 6cf3ae80502be01c31f04477205833a1d15fb37d (patch) | |
tree | fa6567f65d8bbd2b6525e201d8d2b87931cf3912 | |
parent | The default value of option ldap_filter is: undefined. (diff) |
Include IP address, time and module in IBR admin message (thanks to Tsukasa Hamano)
SVN Revision: 2744
-rw-r--r-- | src/mod_register.erl | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/mod_register.erl b/src/mod_register.erl index d8bcbbebd..2ae889c5d 100644 --- a/src/mod_register.erl +++ b/src/mod_register.erl @@ -33,6 +33,7 @@ stop/1, stream_feature_register/1, unauthenticated_iq_register/4, + try_register/5, process_iq/3]). -include("ejabberd.hrl"). @@ -224,7 +225,7 @@ try_register(User, Server, Password, Source, Lang) -> case ejabberd_auth:try_register(User, Server, Password) of {atomic, ok} -> send_welcome_message(JID), - send_registration_notifications(JID), + send_registration_notifications(JID, Source), ok; Error -> remove_timeout(Source), @@ -264,15 +265,17 @@ send_welcome_message(JID) -> ok end. -send_registration_notifications(UJID) -> +send_registration_notifications(UJID, Source) -> Host = UJID#jid.lserver, case gen_mod:get_module_opt(Host, ?MODULE, registration_watchers, []) of [] -> ok; JIDs when is_list(JIDs) -> Body = lists:flatten( io_lib:format( - "The user '~s' was just created on node ~w.", - [jlib:jid_to_string(UJID), node()])), + "[~s] The account ~s was registered from IP address ~s " + "on node ~w using ~p.", + [get_time_string(), jlib:jid_to_string(UJID), + ip_to_string(Source), node(), ?MODULE])), lists:foreach( fun(S) -> case jlib:string_to_jid(S) of @@ -380,3 +383,12 @@ remove_timeout(Source) -> ok end. +ip_to_string(Source) when is_tuple(Source) -> inet_parse:ntoa(Source); +ip_to_string(undefined) -> "undefined"; +ip_to_string(_) -> "unknown". + +get_time_string() -> write_time(erlang:localtime()). +%% Function copied from ejabberd_logger_h.erl and customized +write_time({{Y,Mo,D},{H,Mi,S}}) -> + io_lib:format("~w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w", + [Y, Mo, D, H, Mi, S]). |