+ 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
+ end
+ elseif global_admins then
+ log("error", "Global option 'admins' is not a list");
+ end
+ end
+
+ -- Still not an admin, check with auth provider
+ if not is_admin and host ~= "*" and hosts[host].users and hosts[host].users.is_admin then
+ is_admin = hosts[host].users.is_admin(jid);
+ end
+ return is_admin or false;