# HG changeset patch # User Stephen Paul Weber # Date 1748344868 18000 # Node ID 6164849469f1e7076a3ff36f13501e169fe822ba # Parent 22b5b744fc788632588a5f8c1f0f727bdc6c0d8e mod2_push2: suppress send if none match Rather than sending an empty notification, which is rather unhelpful diff -r 22b5b744fc78 -r 6164849469f1 mod_push2/mod_push2.lua --- a/mod_push2/mod_push2.lua Thu May 22 23:49:29 2025 +0200 +++ b/mod_push2/mod_push2.lua Tue May 27 06:21:08 2025 -0500 @@ -355,6 +355,7 @@ end if send_push then + local any_match = false; local push_notification_payload = st.stanza("notification", { xmlns = xmlns_push }) push_notification_payload:text_tag("client", push_info.client) push_notification_payload:text_tag("priority", is_voip(stanza) and "high" or (is_important(stanza, session) and "normal" or "low")) @@ -411,6 +412,7 @@ if does_match and not sends_added[match.send] then sends_added[match.send] = true + any_match = true if match.send == "urn:xmpp:push2:send:notify-only" then -- Nothing more to add elseif match.send == "urn:xmpp:push2:send:sce+rfc8291+rfc8292:0" then @@ -422,12 +424,15 @@ end end - local push_publish = st.message({ to = push_info.service, from = module.host, id = uuid.generate() }) - :add_child(push_notification_payload):up() + if any_match then + local push_publish = st.message({ to = push_info.service, from = module.host, id = uuid.generate() }) + :add_child(push_notification_payload):up() - -- TODO: watch for message error replies and count or something - module:send(push_publish) - pushes = pushes + 1 + -- TODO: watch for message error replies and count or something +module:log("info", "publish", push_publish) + module:send(push_publish) + pushes = pushes + 1 + end end end