mod_cloud_notify/mod_cloud_notify.lua
changeset 3089 1ea6861b533f
parent 3083 2a918a8c47db
child 3112 cfcb020bcd1d
--- a/mod_cloud_notify/mod_cloud_notify.lua	Fri Jun 01 22:45:41 2018 +0200
+++ b/mod_cloud_notify/mod_cloud_notify.lua	Sat Jun 02 02:58:45 2018 +0200
@@ -138,6 +138,7 @@
 	if node == nil then return false; end		-- unknown stanza? Ignore for now!
 	local from = stanza.attr.from;
 	local user_push_services = push_store:get(node);
+	local changed = false;
 	
 	for push_identifier, _ in pairs(user_push_services) do
 		local stanza_id = hashes.sha256(push_identifier, true);
@@ -159,7 +160,8 @@
 						end
 					end
 					-- save changed global config
-					push_store:set_identifier(node, push_identifier, nil);
+					changed = true;
+					user_push_services[push_identifier] = nil
 					push_errors[push_identifier] = nil;
 					-- unhook iq handlers for this identifier (if possible)
 					if module.unhook then
@@ -174,6 +176,9 @@
 			end
 		end
 	end
+	if changed then
+		push_store:set(node, user_push_services);
+	end
 	return true;
 end