Skip to content

Commit

Permalink
Run user_receive_packet in send_message so MAM stores also incoming (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
badlop committed Sep 3, 2020
1 parent eada3b6 commit 43f813d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/mod_admin_extra.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 43f813d

Please sign in to comment.