Comparison

mod_cloud_notify/mod_cloud_notify.lua @ 2262:19fbf190b5a7

mod_cloud_notify: Log when sending notifications
author Kim Alvefur <zash@zash.se>
date Thu, 28 Jul 2016 13:18:46 +0200
parent 2261:a276fdabf768
child 2263:92af641fcf48
comparison
equal deleted inserted replaced
2261:a276fdabf768 2262:19fbf190b5a7
99 local to = stanza.attr.to; 99 local to = stanza.attr.to;
100 local node = to and jid.split(to) or origin.username; 100 local node = to and jid.split(to) or origin.username;
101 local user_push_services = push_enabled:get(node); 101 local user_push_services = push_enabled:get(node);
102 if not user_push_services then return end 102 if not user_push_services then return end
103 103
104 module:log("debug", "New message to %s@%s, sending push notifications", node, module.host);
104 for _, push_info in pairs(user_push_services) do 105 for _, push_info in pairs(user_push_services) do
105 push_info.count = push_info.count + 1; 106 push_info.count = push_info.count + 1;
106 local push_jid, push_node = push_info.jid, push_info.node; 107 local push_jid, push_node = push_info.jid, push_info.node;
107 local push_publish = st.iq({ to = push_jid, from = node .. "@" .. module.host, type = "set", id = "push" }) 108 local push_publish = st.iq({ to = push_jid, from = node .. "@" .. module.host, type = "set", id = "push" })
108 :tag("pubsub", { xmlns = "http://jabber.org/protocol/pubsub" }) 109 :tag("pubsub", { xmlns = "http://jabber.org/protocol/pubsub" })
123 push_publish:up(); -- / publish 124 push_publish:up(); -- / publish
124 push_publish:up(); -- / pubsub 125 push_publish:up(); -- / pubsub
125 if push_info.options then 126 if push_info.options then
126 push_publish:tag("publish-options"):add_child(st.deserialize(push_info.options)); 127 push_publish:tag("publish-options"):add_child(st.deserialize(push_info.options));
127 end 128 end
129 module:log("debug", "Sending notification to %s", push_jid);
128 module:send(push_publish); 130 module:send(push_publish);
129 end 131 end
130 push_enabled:set(node, user_push_services); 132 push_enabled:set(node, user_push_services);
131 end 133 end
132 134