diff mod_cloud_notify/mod_cloud_notify.lua @ 2260:8cc8e964812b

mod_cloud_notify: Save data after changes
author Kim Alvefur <zash@zash.se>
date Thu, 28 Jul 2016 12:37:20 +0200
parents e0808be13d77
children a276fdabf768
line wrap: on
line diff
--- a/mod_cloud_notify/mod_cloud_notify.lua	Thu Jul 28 12:36:59 2016 +0200
+++ b/mod_cloud_notify/mod_cloud_notify.lua	Thu Jul 28 12:37:20 2016 +0200
@@ -127,6 +127,7 @@
 		end
 		module:send(push_publish);
 	end
+	push_enabled:set(origin.username, user_push_services);
 end
 
 -- publish on offline message
@@ -177,7 +178,8 @@
 
 
 module:hook("message/offline/broadcast", function(event)
-	local user_push_services = push_enabled:get(event.origin.username);
+	local origin = event.origin;
+	local user_push_services = push_enabled:get(origin.username);
 	if not user_push_services then return end
 
 	for _, push_info in pairs(user_push_services) do
@@ -185,4 +187,5 @@
 			push_info.count = 0;
 		end
 	end
+	push_enabled:set(origin.username, user_push_services);
 end, 1);