mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-20 17:27:00 +01:00
Include IP address, time and module in IBR admin message (thanks to Tsukasa Hamano)
SVN Revision: 2744
This commit is contained in:
parent
26c572b7e7
commit
6cf3ae8050
@ -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]).
|
||||
|
Loading…
Reference in New Issue
Block a user