Diff

mod_push2/mod_push2.lua @ 6273:8ceedc336d0d

Merge update
author Trần H. Trung <xmpp:trần.h.trung@trung.fun>
date Sun, 01 Jun 2025 13:51:38 +0700
parent 6267:ff7d6ee9db20
child 6311:27bb0bc3f4b5
line wrap: on
line diff
--- a/mod_push2/mod_push2.lua	Sun Jun 01 11:43:16 2025 +0700
+++ b/mod_push2/mod_push2.lua	Sun Jun 01 13:51:38 2025 +0700
@@ -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,14 @@
 				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:send(push_publish)
+				pushes = pushes + 1
+			end
 		end
 	end