25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

Skip non-delivery errors for local pubsub generated notifications

Those are ignored by pubsub service anyway, so we can skip those, and
reduce number of messages processed by pubsub process.
This commit is contained in:
Paweł Chmielowski 2024-09-11 13:20:53 +02:00
parent cc377bbebf
commit d4b30957a3
2 changed files with 16 additions and 2 deletions

View File

@ -206,6 +206,18 @@ bounce_offline_message(Acc) ->
Acc. Acc.
-spec bounce_sm_packet({bounce | term(), stanza()}) -> any(). -spec bounce_sm_packet({bounce | term(), stanza()}) -> any().
bounce_sm_packet({bounce, #message{meta = #{ignore_sm_bounce := true}} = Packet} = Acc) ->
?DEBUG("Dropping packet to unavailable resource:~n~ts",
[xmpp:pp(Packet)]),
Acc;
bounce_sm_packet({bounce, #iq{meta = #{ignore_sm_bounce := true}} = Packet} = Acc) ->
?DEBUG("Dropping packet to unavailable resource:~n~ts",
[xmpp:pp(Packet)]),
Acc;
bounce_sm_packet({bounce, #presence{meta = #{ignore_sm_bounce := true}} = Packet} = Acc) ->
?DEBUG("Dropping packet to unavailable resource:~n~ts",
[xmpp:pp(Packet)]),
Acc;
bounce_sm_packet({bounce, Packet} = Acc) -> bounce_sm_packet({bounce, Packet} = Acc) ->
Lang = xmpp:get_lang(Packet), Lang = xmpp:get_lang(Packet),
Txt = ?T("User session not found"), Txt = ?T("User session not found"),

View File

@ -3029,7 +3029,8 @@ broadcast_stanza(Host, _Node, _Nidx, _Type, NodeOptions, SubsByDepth, NotifyType
end, end,
lists:foreach(fun(To) -> lists:foreach(fun(To) ->
ejabberd_router:route( ejabberd_router:route(
xmpp:set_to(StanzaToSend, jid:make(To))) xmpp:set_to(xmpp:put_meta(StanzaToSend, ignore_sm_bounce, true),
jid:make(To)))
end, LJIDs) end, LJIDs)
end, SubIDsByJID). end, SubIDsByJID).
@ -3052,7 +3053,8 @@ broadcast_stanza({LUser, LServer, LResource}, Publisher, Node, Nidx, Type, NodeO
Pred = fun(To) -> delivery_permitted(Owner, To, NodeOptions) end, Pred = fun(To) -> delivery_permitted(Owner, To, NodeOptions) end,
ejabberd_sm:route(jid:make(LUser, LServer, SenderResource), ejabberd_sm:route(jid:make(LUser, LServer, SenderResource),
{pep_message, <<((Node))/binary, "+notify">>, Stanza, Pred}), {pep_message, <<((Node))/binary, "+notify">>, Stanza, Pred}),
ejabberd_router:route(xmpp:set_to(Stanza, jid:make(LUser, LServer))); ejabberd_router:route(xmpp:set_to(xmpp:put_meta(Stanza, ignore_sm_bounce, true),
jid:make(LUser, LServer)));
broadcast_stanza(Host, _Publisher, Node, Nidx, Type, NodeOptions, SubsByDepth, NotifyType, BaseStanza, SHIM) -> broadcast_stanza(Host, _Publisher, Node, Nidx, Type, NodeOptions, SubsByDepth, NotifyType, BaseStanza, SHIM) ->
broadcast_stanza(Host, Node, Nidx, Type, NodeOptions, SubsByDepth, NotifyType, BaseStanza, SHIM). broadcast_stanza(Host, Node, Nidx, Type, NodeOptions, SubsByDepth, NotifyType, BaseStanza, SHIM).