- if host and host ~= "*" then
- return hosts[host].users.is_admin(jid);
- else -- Test only whether this JID is a global admin
- local admins = config.get("*", "core", "admins");
- if type(admins) == "table" then
- jid = jid_bare(jid);
- for _,admin in ipairs(admins) do
- if admin == jid then return true; end
+ if host and not hosts[host] then return false; end
+ if type(jid) ~= "string" then return false; end
+
+ local is_admin;
+ jid = jid_bare(jid);
+ host = host or "*";
+
+ local host_admins = config.get(host, "admins");
+ local global_admins = config.get("*", "admins");
+
+ if host_admins and host_admins ~= global_admins then
+ if type(host_admins) == "table" then
+ for _,admin in ipairs(host_admins) do
+ if jid_prep(admin) == jid then
+ is_admin = true;
+ break;
+ end
+ end
+ elseif host_admins then
+ log("error", "Option 'admins' for host '%s' is not a list", host);
+ end
+ end
+
+ if not is_admin and global_admins then
+ if type(global_admins) == "table" then
+ for _,admin in ipairs(global_admins) do
+ if jid_prep(admin) == jid then
+ is_admin = true;
+ break;
+ end