mirror of
https://github.com/processone/ejabberd.git
synced 2024-10-09 15:06:54 +02:00
Trigger hook for user_send_packet in send_message command (#2604)
This commit is contained in:
parent
a7a1e7be94
commit
1d6cbd2561
@ -1450,12 +1450,17 @@ srg_user_del(User, Host, Group, GroupHost) ->
|
||||
send_message(Type, From, To, Subject, Body) ->
|
||||
FromJID = jid:decode(From),
|
||||
ToJID = jid:decode(To),
|
||||
Packet = build_packet(Type, Subject, Body),
|
||||
Packet = build_packet(Type, Subject, Body, FromJID, ToJID),
|
||||
State1 = #{jid => FromJID},
|
||||
{Pkt2, State2} = ejabberd_hooks:run_fold(
|
||||
user_send_packet, FromJID#jid.lserver, {Packet, State1}, []),
|
||||
ejabberd_router:route(xmpp:set_from_to(Packet, FromJID, ToJID)).
|
||||
|
||||
build_packet(Type, Subject, Body) ->
|
||||
build_packet(Type, Subject, Body, FromJID, ToJID) ->
|
||||
#message{type = misc:binary_to_atom(Type),
|
||||
body = xmpp:mk_text(Body),
|
||||
from = FromJID,
|
||||
to = ToJID,
|
||||
id = p1_rand:get_string(),
|
||||
subject = xmpp:mk_text(Subject)}.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user