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

Run user_receive_packet in send_message so MAM stores also incoming (#3377)

This commit is contained in:
Badlop 2020-09-03 17:35:57 +02:00
parent eada3b6e93
commit 43f813d6f8

View File

@ -1494,14 +1494,18 @@ send_message(Type, From, To, Subject, Body) ->
#xmlel{name = <<"body">>,
children = [{xmlcdata, Body}]}]},
?NS_CLIENT, CodecOpts) of
#message{from = JID} = Msg ->
State = #{jid => JID},
ejabberd_hooks:run_fold(user_send_packet, JID#jid.lserver, {Msg, State}, []),
#message{from = FromJid, to = ToJid} = Msg1 ->
Msg = xmpp:put_meta(Msg1, stanza_id, mod_mam:make_id()),
ejabberd_hooks:run_fold(user_send_packet, FromJid#jid.lserver,
{Msg, #{jid => FromJid}}, []),
ejabberd_hooks:run_fold(user_receive_packet, FromJid#jid.lserver,
{Msg, #{jid => ToJid}}, []),
ejabberd_router:route(Msg)
catch _:{xmpp_codec, Why} ->
{error, xmpp:format_error(Why)}
end.
send_stanza(FromString, ToString, Stanza) ->
try
#xmlel{} = El = fxml_stream:parse_element(Stanza),