# HG changeset patch # User Florian Zeitz # Date 1343781223 -7200 # Node ID 48f8b312a509e467d3b474dc288134ad83d2a5a7 # Parent 442f88b49d9bf1dc534afdafbfc043c52c65e240 mod_admin_web: Replace core_post_stanza() with module:send() diff -r 442f88b49d9b -r 48f8b312a509 mod_admin_web/admin_web/mod_admin_web.lua --- 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