Skip to content

Commit

Permalink
feat(prosody): New impl of is_admin.
Browse files Browse the repository at this point in the history
  • Loading branch information
damencho committed Feb 21, 2025
1 parent fa801b4 commit 15403dc
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions resources/prosody-plugins/util.lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ local cache = require "util.cache";
local array = require "util.array";
local is_set = require 'util.set'.is_set;
local usermanager = require 'core.usermanager';
local normalize = require 'prosody.util.jid'.prep;

local config_global_admin_jids = module:context('*'):get_option_set('admins', {}) / normalize;
local config_admin_jids = module:get_option_inherited_set('admins', {}) / normalize;

local http_timeout = 30;
local have_async, async = pcall(require, "util.async");
Expand Down Expand Up @@ -628,15 +632,23 @@ function get_ip(session)
end

-- Checks whether the provided jid is in the list of admins
local function is_admin(jid)
return usermanager.is_admin(jid, module.host);
-- we are not using the new permissions and roles api as we have few global modules which need to be
-- refactored into host modules, as that api needs to be executed in host context
local function is_admin(_jid)
local bare_jid = jid.bare(_jid);

if config_global_admin_jids:contains(bare_jid) or config_admin_jids:contains(bare_jid) then
return true;
end
return false;
end

return {
OUTBOUND_SIP_JIBRI_PREFIXES = OUTBOUND_SIP_JIBRI_PREFIXES;
INBOUND_SIP_JIBRI_PREFIXES = INBOUND_SIP_JIBRI_PREFIXES;
RECORDER_PREFIXES = RECORDER_PREFIXES;
extract_subdomain = extract_subdomain;
is_admin = is_admin;
is_feature_allowed = is_feature_allowed;
is_jibri = is_jibri;
is_healthcheck_room = is_healthcheck_room;
Expand Down

0 comments on commit 15403dc

Please sign in to comment.