diff mod_cloud_notify/mod_cloud_notify.lua @ 3079:2a918a8c47db

mod_cloud_notify: use next() instead of # operator and update README
author tmolitor <thilo@eightysoft.de>
date Fri, 01 Jun 2018 18:24:34 +0200
parents 6b860de18a53
children 1ea6861b533f
line wrap: on
line diff
--- a/mod_cloud_notify/mod_cloud_notify.lua	Fri Jun 01 17:54:07 2018 +0200
+++ b/mod_cloud_notify/mod_cloud_notify.lua	Fri Jun 01 18:24:34 2018 +0200
@@ -8,6 +8,7 @@
 local s_match = string.match;
 local s_sub = string.sub;
 local os_time = os.time;
+local next = next;
 local st = require"util.stanza";
 local jid = require"util.jid";
 local dataform = require"util.dataforms".new;
@@ -360,7 +361,7 @@
 -- http://xmpp.org/extensions/xep-0357.html#publishing
 local function handle_notify_request(stanza, node, user_push_services)
 	local pushes = 0;
-	if not user_push_services or not #user_push_services then return pushes end
+	if not user_push_services or next(user_push_services) == nil then return pushes end
 	
 	for push_identifier, push_info in pairs(user_push_services) do
 		local send_push = true;		-- only send push to this node when not already done for this stanza or if no stanza is given at all
@@ -496,7 +497,7 @@
 	-- only notify if the stanza destination is the mam user we store it for
 	if event.for_user == to then
 		local user_push_services = push_store:get(to);
-		if not #user_push_services then return end
+		if next(user_push_services) == nil then return end
 		
 		-- only notify nodes with no active sessions (smacks is counted as active and handled separate)
 		local notify_push_sevices = {};