Software /
code /
prosody-modules
Changeset
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 |
parents | 760:442f88b49d9b |
children | 762:0a06cf46c263 |
files | mod_admin_web/admin_web/mod_admin_web.lua |
diffstat | 1 files changed, 16 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_admin_web/admin_web/mod_admin_web.lua Wed Aug 01 02:30:30 2012 +0200 +++ b/mod_admin_web/admin_web/mod_admin_web.lua Wed Aug 01 02:33:43 2012 +0200 @@ -144,10 +144,25 @@ } }); + local function simple_broadcast(node, jids, item) + item = st.clone(item); + item.attr.xmlns = nil; -- Clear the pubsub namespace + local message = st.message({ from = module.host, type = "headline" }) + :tag("event", { xmlns = xmlns_adminsub .. "#event" }) + :tag("items", { node = node }) + :add_child(item); + for jid in pairs(jids) do + module:log("debug", "Sending notification to %s", jid); + message.attr.to = jid; + module:send(message); + end + end + + -- Setup adminsub service local ok, err; service[module.host] = pubsub.new({ - broadcaster = function(node, jids, item) return simple_broadcast(node, jids, item, module.host) end; + broadcaster = simple_broadcast; normalize_jid = jid_bare; get_affiliation = function(jid) return get_affiliation(jid, module.host) end; capabilities = { @@ -321,20 +336,6 @@ end); end -function simple_broadcast(node, jids, item, host) - item = st.clone(item); - item.attr.xmlns = nil; -- Clear the pubsub namespace - local message = st.message({ from = host, type = "headline" }) - :tag("event", { xmlns = xmlns_adminsub .. "#event" }) - :tag("items", { node = node }) - :add_child(item); - for jid in pairs(jids) do - module:log("debug", "Sending notification to %s", jid); - message.attr.to = jid; - core_post_stanza(hosts[host], message); - end -end - function get_affiliation(jid, host) local bare_jid = jid_bare(jid); if is_admin(bare_jid, host) then