25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

Fix previous commit

This commit is contained in:
Evgeniy Khramtsov 2017-03-02 15:34:26 +03:00
parent cebdb87387
commit 4e014b4c5c

View File

@ -57,41 +57,27 @@ depends(_Host, _Opts) ->
-spec log_user_send({stanza(), ejabberd_c2s:state()}) -> {stanza(), ejabberd_c2s:state()}.
log_user_send({Packet, C2SState}) ->
From = xmpp:get_from(Packet),
To = xmpp:get_to(Packet),
log_packet(From, To, Packet, From#jid.lserver),
log_packet(Packet, From#jid.lserver),
{Packet, C2SState}.
-spec log_user_receive({stanza(), ejabberd_c2s:state()}) -> {stanza(), ejabberd_c2s:state()}.
log_user_receive({Packet, C2SState}) ->
From = xmpp:get_from(Packet),
To = xmpp:get_to(Packet),
log_packet(From, To, Packet, To#jid.lserver),
log_packet(Packet, To#jid.lserver),
{Packet, C2SState}.
-spec log_packet(jid(), jid(), stanza(), binary()) -> ok.
log_packet(From, To, Packet, Host) ->
-spec log_packet(stanza(), binary()) -> ok.
log_packet(Packet, Host) ->
Loggers = gen_mod:get_module_opt(Host, ?MODULE, loggers,
fun(L) ->
lists:map(
fun(S) ->
B = iolist_to_binary(S),
N = jid:nameprep(B),
if N /= error ->
N
end
end, L)
end, []),
ServerJID = jid:make(Host),
FixedPacket = xmpp:set_from_to(Packet, From, To),
lists:foreach(fun (Logger) ->
ejabberd_router:route(ServerJID,
jid:make(Logger),
#xmlel{name = <<"route">>,
attrs = [],
children =
[FixedPacket]})
end,
Loggers).
mod_opt_type(loggers), []),
ForwardedMsg = #message{from = jid:make(Host),
id = randoms:get_string(),
sub_els = [#forwarded{
xml_els = [xmpp:encode(Packet)]}]},
lists:foreach(
fun(Logger) ->
ejabberd_router:route(xmpp:set_to(ForwardedMsg, jid:make(Logger)))
end, Loggers).
mod_opt_type(loggers) ->
fun (L) ->