]> granicus.if.org Git - ejabberd/commitdiff
Trigger hook for user_send_packet in send_message command (#2604)
authorBadlop <badlop@process-one.net>
Thu, 13 Sep 2018 15:58:32 +0000 (17:58 +0200)
committerBadlop <badlop@process-one.net>
Thu, 13 Sep 2018 16:21:30 +0000 (18:21 +0200)
src/mod_admin_extra.erl

index 1b3b27d38ed0d22294c0bdc6464af9a29e82588c..851941fa856a0701723934ba3e7288fe074c7070 100644 (file)
@@ -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)}.