25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

Trigger user_send_packet when send_stanza API is called (#3431)

This commit is contained in:
Badlop 2020-12-01 13:06:04 +01:00
parent f48f9fee2e
commit d75d69d5d5

View File

@ -1509,7 +1509,11 @@ send_stanza(FromString, ToString, Stanza) ->
To = jid:decode(ToString), To = jid:decode(ToString),
CodecOpts = ejabberd_config:codec_options(), CodecOpts = ejabberd_config:codec_options(),
Pkt = xmpp:decode(El, ?NS_CLIENT, CodecOpts), Pkt = xmpp:decode(El, ?NS_CLIENT, CodecOpts),
ejabberd_router:route(xmpp:set_from_to(Pkt, From, To)) Pkt2 = xmpp:set_from_to(Pkt, From, To),
State = #{jid => From},
ejabberd_hooks:run_fold(user_send_packet, From#jid.lserver,
{Pkt2, State}, []),
ejabberd_router:route(Pkt2)
catch _:{xmpp_codec, Why} -> catch _:{xmpp_codec, Why} ->
io:format("incorrect stanza: ~ts~n", [xmpp:format_error(Why)]), io:format("incorrect stanza: ~ts~n", [xmpp:format_error(Why)]),
{error, Why}; {error, Why};