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,
|
stop/1,
|
||||||
stream_feature_register/1,
|
stream_feature_register/1,
|
||||||
unauthenticated_iq_register/4,
|
unauthenticated_iq_register/4,
|
||||||
|
try_register/5,
|
||||||
process_iq/3]).
|
process_iq/3]).
|
||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
@ -224,7 +225,7 @@ try_register(User, Server, Password, Source, Lang) ->
|
|||||||
case ejabberd_auth:try_register(User, Server, Password) of
|
case ejabberd_auth:try_register(User, Server, Password) of
|
||||||
{atomic, ok} ->
|
{atomic, ok} ->
|
||||||
send_welcome_message(JID),
|
send_welcome_message(JID),
|
||||||
send_registration_notifications(JID),
|
send_registration_notifications(JID, Source),
|
||||||
ok;
|
ok;
|
||||||
Error ->
|
Error ->
|
||||||
remove_timeout(Source),
|
remove_timeout(Source),
|
||||||
@ -264,15 +265,17 @@ send_welcome_message(JID) ->
|
|||||||
ok
|
ok
|
||||||
end.
|
end.
|
||||||
|
|
||||||
send_registration_notifications(UJID) ->
|
send_registration_notifications(UJID, Source) ->
|
||||||
Host = UJID#jid.lserver,
|
Host = UJID#jid.lserver,
|
||||||
case gen_mod:get_module_opt(Host, ?MODULE, registration_watchers, []) of
|
case gen_mod:get_module_opt(Host, ?MODULE, registration_watchers, []) of
|
||||||
[] -> ok;
|
[] -> ok;
|
||||||
JIDs when is_list(JIDs) ->
|
JIDs when is_list(JIDs) ->
|
||||||
Body = lists:flatten(
|
Body = lists:flatten(
|
||||||
io_lib:format(
|
io_lib:format(
|
||||||
"The user '~s' was just created on node ~w.",
|
"[~s] The account ~s was registered from IP address ~s "
|
||||||
[jlib:jid_to_string(UJID), node()])),
|
"on node ~w using ~p.",
|
||||||
|
[get_time_string(), jlib:jid_to_string(UJID),
|
||||||
|
ip_to_string(Source), node(), ?MODULE])),
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(S) ->
|
fun(S) ->
|
||||||
case jlib:string_to_jid(S) of
|
case jlib:string_to_jid(S) of
|
||||||
@ -380,3 +383,12 @@ remove_timeout(Source) ->
|
|||||||
ok
|
ok
|
||||||
end.
|
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