comparison mod_cloud_notify/mod_cloud_notify.lua @ 2252:a96f2d0f8750

mod_cloud_notify: Add some logging when a client attempts to enable push notifications
author Kim Alvefur <zash@zash.se>
date Tue, 26 Jul 2016 13:08:44 +0200
parents d09014d8c901
children 97ebd28a8a75
comparison
equal deleted inserted replaced
2251:48c3d64a3fc1 2252:a96f2d0f8750
24 end); 24 end);
25 25
26 -- http://xmpp.org/extensions/xep-0357.html#enabling 26 -- http://xmpp.org/extensions/xep-0357.html#enabling
27 module:hook("iq-set/self/"..xmlns_push..":enable", function (event) 27 module:hook("iq-set/self/"..xmlns_push..":enable", function (event)
28 local origin, stanza = event.origin, event.stanza; 28 local origin, stanza = event.origin, event.stanza;
29 origin.log("debug", "Attempting to enable push notifications");
29 -- MUST contain a 'jid' attribute of the XMPP Push Service being enabled 30 -- MUST contain a 'jid' attribute of the XMPP Push Service being enabled
30 local push_jid = stanza.tags[1].attr.jid; 31 local push_jid = stanza.tags[1].attr.jid;
31 -- SHOULD contain a 'node' attribute 32 -- SHOULD contain a 'node' attribute
32 local push_node = stanza.tags[1].attr.node; 33 local push_node = stanza.tags[1].attr.node;
33 if not push_jid then 34 if not push_jid then
51 }; 52 };
52 local ok, err = push_enabled:set(origin.username, user_push_services); 53 local ok, err = push_enabled:set(origin.username, user_push_services);
53 if not ok then 54 if not ok then
54 origin.send(st.error_reply(stanza, "wait", "internal-server-error")); 55 origin.send(st.error_reply(stanza, "wait", "internal-server-error"));
55 else 56 else
57 origin.log("info", "Push notifications enabled");
56 origin.send(st.reply(stanza)); 58 origin.send(st.reply(stanza));
57 end 59 end
58 return true; 60 return true;
59 end); 61 end);
60 62