Skip to content

Commit 72661ac

Browse files
committed
Merge remote-tracking branch 'processone/pr/4383'
* processone/pr/4383: feat: fire new `push_send_notification` hook
2 parents eace76b + cda1d4c commit 72661ac

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/mod_push.erl

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -526,12 +526,19 @@ notify(LServer, PushLJID, Node, XData, Pkt0, Dir, HandleResponse) ->
526526
Item = #ps_item{sub_els = [#push_notification{xdata = Summary}]},
527527
PubSub = #pubsub{publish = #ps_publish{node = Node, items = [Item]},
528528
publish_options = XData},
529-
IQ = #iq{type = set,
530-
from = From,
531-
to = jid:make(PushLJID),
532-
id = p1_rand:get_string(),
533-
sub_els = [PubSub]},
534-
ejabberd_router:route_iq(IQ, HandleResponse)
529+
IQ0 = #iq{type = set,
530+
from = From,
531+
to = jid:make(PushLJID),
532+
id = p1_rand:get_string(),
533+
sub_els = [PubSub]},
534+
case ejabberd_hooks:run_fold(push_send_notification, LServer, IQ0, [Pkt]) of
535+
drop ->
536+
?DEBUG("No push notification will be sent: some hook dropped it", []),
537+
ok;
538+
IQ ->
539+
?DEBUG("Push notification hooks built the definitive IQ to route: ~n~ts", [xmpp:pp(IQ)]),
540+
ejabberd_router:route_iq(IQ, HandleResponse)
541+
end
535542
end.
536543

537544
%%--------------------------------------------------------------------

0 commit comments

Comments
 (0)