comparison 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
comparison
equal deleted inserted replaced
2259:e0808be13d77 2260:8cc8e964812b
125 if push_info.options then 125 if push_info.options then
126 push_publish:tag("publish-options"):add_child(st.deserialize(push_info.options)); 126 push_publish:tag("publish-options"):add_child(st.deserialize(push_info.options));
127 end 127 end
128 module:send(push_publish); 128 module:send(push_publish);
129 end 129 end
130 push_enabled:set(origin.username, user_push_services);
130 end 131 end
131 132
132 -- publish on offline message 133 -- publish on offline message
133 module:hook("message/offline/handle", function(event) 134 module:hook("message/offline/handle", function(event)
134 if event.stanza._notify then 135 if event.stanza._notify then
175 module:hook("smacks-hibernation-start", hibernate_session); 176 module:hook("smacks-hibernation-start", hibernate_session);
176 module:hook("smacks-hibernation-end", restore_session); 177 module:hook("smacks-hibernation-end", restore_session);
177 178
178 179
179 module:hook("message/offline/broadcast", function(event) 180 module:hook("message/offline/broadcast", function(event)
180 local user_push_services = push_enabled:get(event.origin.username); 181 local origin = event.origin;
182 local user_push_services = push_enabled:get(origin.username);
181 if not user_push_services then return end 183 if not user_push_services then return end
182 184
183 for _, push_info in pairs(user_push_services) do 185 for _, push_info in pairs(user_push_services) do
184 if push_info then 186 if push_info then
185 push_info.count = 0; 187 push_info.count = 0;
186 end 188 end
187 end 189 end
190 push_enabled:set(origin.username, user_push_services);
188 end, 1); 191 end, 1);