Mercurial > prosody-modules
comparison mod_cloud_notify/mod_cloud_notify.lua @ 2263:92af641fcf48
mod_cloud_notify: One log message per push sent (happy now Ge0rg?)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 28 Jul 2016 14:47:28 +0200 |
parents | 19fbf190b5a7 |
children | 2e641ab995b3 |
comparison
equal
deleted
inserted
replaced
2262:19fbf190b5a7 | 2263:92af641fcf48 |
---|---|
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); | |
105 for _, push_info in pairs(user_push_services) do | 104 for _, push_info in pairs(user_push_services) do |
106 push_info.count = push_info.count + 1; | 105 push_info.count = push_info.count + 1; |
107 local push_jid, push_node = push_info.jid, push_info.node; | 106 local push_jid, push_node = push_info.jid, push_info.node; |
108 local push_publish = st.iq({ to = push_jid, from = node .. "@" .. module.host, type = "set", id = "push" }) | 107 local push_publish = st.iq({ to = push_jid, from = node .. "@" .. module.host, type = "set", id = "push" }) |
109 :tag("pubsub", { xmlns = "http://jabber.org/protocol/pubsub" }) | 108 :tag("pubsub", { xmlns = "http://jabber.org/protocol/pubsub" }) |
124 push_publish:up(); -- / publish | 123 push_publish:up(); -- / publish |
125 push_publish:up(); -- / pubsub | 124 push_publish:up(); -- / pubsub |
126 if push_info.options then | 125 if push_info.options then |
127 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)); |
128 end | 127 end |
129 module:log("debug", "Sending notification to %s", push_jid); | 128 module:log("debug", "Sending push notification for %s@%s to %s", node, module.host, push_jid); |
130 module:send(push_publish); | 129 module:send(push_publish); |
131 end | 130 end |
132 push_enabled:set(node, user_push_services); | 131 push_enabled:set(node, user_push_services); |
133 end | 132 end |
134 | 133 |