mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-20 17:27:00 +01: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) ->
|
send_message(Type, From, To, Subject, Body) ->
|
||||||
FromJID = jid:decode(From),
|
FromJID = jid:decode(From),
|
||||||
ToJID = jid:decode(To),
|
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)).
|
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),
|
#message{type = misc:binary_to_atom(Type),
|
||||||
body = xmpp:mk_text(Body),
|
body = xmpp:mk_text(Body),
|
||||||
|
from = FromJID,
|
||||||
|
to = ToJID,
|
||||||
id = p1_rand:get_string(),
|
id = p1_rand:get_string(),
|
||||||
subject = xmpp:mk_text(Subject)}.
|
subject = xmpp:mk_text(Subject)}.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user