Changeset

6266:6164849469f1

mod2_push2: suppress send if none match Rather than sending an empty notification, which is rather unhelpful
author Stephen Paul Weber <singpolyma@singpolyma.net>
date Tue, 27 May 2025 06:21:08 -0500
parents 6265:22b5b744fc78
children 6267:ff7d6ee9db20
files mod_push2/mod_push2.lua
diffstat 1 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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