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

Allow for filtering outgoing s2s stanzas (#3381)

Let 's2s_send_packet' hook callbacks filter stanzas, analogous to the
's2s_receive_packet' hook.
This commit is contained in:
Holger Weiß 2020-09-07 10:12:19 +02:00 committed by GitHub
parent a75966f1a2
commit e9a053f7ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -351,8 +351,11 @@ route(Packet) ->
{ok, Pid} when is_pid(Pid) ->
?DEBUG("Sending to process ~p~n", [Pid]),
#jid{lserver = MyServer} = From,
ejabberd_hooks:run(s2s_send_packet, MyServer, [Packet]),
ejabberd_s2s_out:route(Pid, Packet);
case ejabberd_hooks:run_fold(s2s_send_packet, MyServer, Packet,
[]) of
drop -> ok;
Packet1 -> ejabberd_s2s_out:route(Pid, Packet1)
end;
{error, Reason} ->
Lang = xmpp:get_lang(Packet),
Err = case Reason of

View File

@ -103,10 +103,11 @@ user_receive_packet({Packet, #{jid := #jid{lserver = LServer}} = C2SState}) ->
push(LServer, user_receive_packet),
{Packet, C2SState}.
-spec s2s_send_packet(stanza()) -> any().
-spec s2s_send_packet(stanza()) -> stanza().
s2s_send_packet(Packet) ->
#jid{lserver = LServer} = xmpp:get_from(Packet),
push(LServer, s2s_send_packet).
push(LServer, s2s_send_packet),
Packet.
-spec s2s_receive_packet({stanza(), ejabberd_s2s_in:state()}) ->
{stanza(), ejabberd_s2s_in:state()}.