Software /
code /
prosody-modules
Comparison
mod_admin_web/admin_web/mod_admin_web.lua @ 761:48f8b312a509
mod_admin_web: Replace core_post_stanza() with module:send()
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Wed, 01 Aug 2012 02:33:43 +0200 |
parent | 753:9d5731af2c27 |
child | 769:7076f58b9f48 |
comparison
equal
deleted
inserted
replaced
760:442f88b49d9b | 761:48f8b312a509 |
---|---|
142 end; | 142 end; |
143 ["GET /*"] = serve_file; | 143 ["GET /*"] = serve_file; |
144 } | 144 } |
145 }); | 145 }); |
146 | 146 |
147 local function simple_broadcast(node, jids, item) | |
148 item = st.clone(item); | |
149 item.attr.xmlns = nil; -- Clear the pubsub namespace | |
150 local message = st.message({ from = module.host, type = "headline" }) | |
151 :tag("event", { xmlns = xmlns_adminsub .. "#event" }) | |
152 :tag("items", { node = node }) | |
153 :add_child(item); | |
154 for jid in pairs(jids) do | |
155 module:log("debug", "Sending notification to %s", jid); | |
156 message.attr.to = jid; | |
157 module:send(message); | |
158 end | |
159 end | |
160 | |
161 | |
147 -- Setup adminsub service | 162 -- Setup adminsub service |
148 local ok, err; | 163 local ok, err; |
149 service[module.host] = pubsub.new({ | 164 service[module.host] = pubsub.new({ |
150 broadcaster = function(node, jids, item) return simple_broadcast(node, jids, item, module.host) end; | 165 broadcaster = simple_broadcast; |
151 normalize_jid = jid_bare; | 166 normalize_jid = jid_bare; |
152 get_affiliation = function(jid) return get_affiliation(jid, module.host) end; | 167 get_affiliation = function(jid) return get_affiliation(jid, module.host) end; |
153 capabilities = { | 168 capabilities = { |
154 member = { | 169 member = { |
155 create = false; | 170 create = false; |
319 module:hook("s2sin-destroyed", function(event) | 334 module:hook("s2sin-destroyed", function(event) |
320 del_host(event.session, "in", module.host); | 335 del_host(event.session, "in", module.host); |
321 end); | 336 end); |
322 end | 337 end |
323 | 338 |
324 function simple_broadcast(node, jids, item, host) | |
325 item = st.clone(item); | |
326 item.attr.xmlns = nil; -- Clear the pubsub namespace | |
327 local message = st.message({ from = host, type = "headline" }) | |
328 :tag("event", { xmlns = xmlns_adminsub .. "#event" }) | |
329 :tag("items", { node = node }) | |
330 :add_child(item); | |
331 for jid in pairs(jids) do | |
332 module:log("debug", "Sending notification to %s", jid); | |
333 message.attr.to = jid; | |
334 core_post_stanza(hosts[host], message); | |
335 end | |
336 end | |
337 | |
338 function get_affiliation(jid, host) | 339 function get_affiliation(jid, host) |
339 local bare_jid = jid_bare(jid); | 340 local bare_jid = jid_bare(jid); |
340 if is_admin(bare_jid, host) then | 341 if is_admin(bare_jid, host) then |
341 return "member"; | 342 return "member"; |
342 else | 343 else |