# HG changeset patch # User Florian Zeitz # Date 1428098043 -7200 # Node ID 95b8b1f9a88210974ed8b3f602acc4cf559317a0 # Parent 9a862059bd9741aaab5c8689262d169d3dd84eea mod_admin_web: Cleanup diff -r 9a862059bd97 -r 95b8b1f9a882 mod_admin_web/admin_web/mod_admin_web.lua --- a/mod_admin_web/admin_web/mod_admin_web.lua Thu Apr 02 18:51:13 2015 -0700 +++ b/mod_admin_web/admin_web/mod_admin_web.lua Fri Apr 03 23:54:03 2015 +0200 @@ -23,6 +23,9 @@ local pubsub = require "util.pubsub"; local jid_bare = require "util.jid".bare; +local hosts = prosody.hosts; +local incoming_s2s = prosody.incoming_s2s; + module:set_global(); local service = {}; @@ -33,7 +36,7 @@ local idmap = {}; -function add_client(session, host) +local function add_client(session, host) local name = session.full_jid; local id = idmap[name]; if not id then @@ -56,7 +59,7 @@ module:log("debug", "Added client " .. name); end -function del_client(session, host) +local function del_client(session, host) local name = session.full_jid; local id = idmap[name]; if id then @@ -65,7 +68,7 @@ end end -function add_host(session, type, host) +local function add_host(session, type, host) local name = (type == "out" and session.to_host) or (type == "in" and session.from_host); local id = idmap[name.."_"..type]; if not id then @@ -96,7 +99,7 @@ module:log("debug", "Added host " .. name .. " s2s" .. type); end -function del_host(session, type, host) +local function del_host(session, type, host) local name = (type == "out" and session.to_host) or (type == "in" and session.from_host); local id = idmap[name.."_"..type]; if id then @@ -105,6 +108,15 @@ end end +local function get_affiliation(jid, host) + local bare_jid = jid_bare(jid); + if is_admin(bare_jid, host) then + return "member"; + else + return "none"; + end +end + function module.add_host(module) -- Dependencies module:depends("bosh"); @@ -143,7 +155,6 @@ end end - local ok, err; service[module.host] = pubsub.new({ broadcaster = simple_broadcast; normalize_jid = jid_bare; @@ -198,7 +209,7 @@ }); -- Create node for s2s sessions - ok, err = service[module.host]:create(xmlns_s2s_session, true); + local ok, err = service[module.host]:create(xmlns_s2s_session, true); if not ok then module:log("warn", "Could not create node " .. xmlns_s2s_session .. ": " .. tostring(err)); else @@ -206,7 +217,7 @@ end -- Add outgoing s2s sessions - for remotehost, session in pairs(hosts[module.host].s2sout) do + for _, session in pairs(hosts[module.host].s2sout) do if session.type ~= "s2sout_unauthed" then add_host(session, "out", module.host); end @@ -228,8 +239,8 @@ end -- Add c2s sessions - for username, user in pairs(hosts[module.host].sessions or {}) do - for resource, session in pairs(user.sessions or {}) do + for _, user in pairs(hosts[module.host].sessions or {}) do + for _, session in pairs(user.sessions or {}) do add_client(session, module.host); end end @@ -318,12 +329,3 @@ del_host(event.session, "in", module.host); end); end - -function get_affiliation(jid, host) - local bare_jid = jid_bare(jid); - if is_admin(bare_jid, host) then - return "member"; - else - return "none"; - end -end