diff options
author | Kim Alvefur <zash@zash.se> | 2025-03-22 11:56:23 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2025-03-22 11:56:23 +0100 |
commit | 244220453d3f8044bd93c577f9e635df285edad7 (patch) | |
tree | a1d7246ed4d066c7219f4b4ff54aea2081f81572 | |
parent | 8a4d96bb71ea4a3d9e46d9ffd034d5e25d7602e5 (diff) | |
parent | 6959547703da2b8137005e391863e7e6399109a6 (diff) | |
download | prosody-244220453d3f8044bd93c577f9e635df285edad7.tar.gz prosody-244220453d3f8044bd93c577f9e635df285edad7.zip |
Merge 13.0->trunk
-rw-r--r-- | core/usermanager.lua | 3 | ||||
-rw-r--r-- | plugins/mod_storage_sql.lua | 56 | ||||
-rw-r--r-- | spec/core_storagemanager_spec.lua | 2 |
3 files changed, 31 insertions, 30 deletions
diff --git a/core/usermanager.lua b/core/usermanager.lua index c179e21b..beac547d 100644 --- a/core/usermanager.lua +++ b/core/usermanager.lua @@ -307,7 +307,8 @@ local function is_admin(jid, host) end log("warn", "Usage of legacy is_admin() API, which will be disabled in a future build: %s", debug.traceback()); log("warn", "See https://prosody.im/doc/developers/permissions about the new permissions API"); - return legacy_admin_roles[get_jid_role(jid, host)] or false; + local role = get_jid_role(jid, host); + return role and legacy_admin_roles[role.name] or false; end local function get_users_with_role(role, host) diff --git a/plugins/mod_storage_sql.lua b/plugins/mod_storage_sql.lua index ff44adba..5f80fad7 100644 --- a/plugins/mod_storage_sql.lua +++ b/plugins/mod_storage_sql.lua @@ -866,38 +866,38 @@ local function upgrade_table(engine, params, apply_changes) -- luacheck: ignore success,err = engine:transaction(function() return engine:execute(check_encoding_query, params.database, engine.charset, engine.charset.."_bin"); - end); - if not success then - module:log("error", "Failed to check/upgrade database encoding: %s", err or "unknown error"); - return false; - end - else - local indices = {}; - engine:transaction(function () - if params.driver == "SQLite3" then - for row in engine:select [[SELECT "name" FROM "sqlite_schema" WHERE "type"='index' AND "tbl_name"='prosody' AND "name"='prosody_index';]] do - indices[row[1]] = true; - end - elseif params.driver == "PostgreSQL" then - for row in engine:select [[SELECT "indexname" FROM "pg_indexes" WHERE "tablename"='prosody' AND "indexname"='prosody_index';]] do - indices[row[1]] = true; - end + end); + if not success then + module:log("error", "Failed to check/upgrade database encoding: %s", err or "unknown error"); + return false; + end + else + local indices = {}; + engine:transaction(function () + if params.driver == "SQLite3" then + for row in engine:select [[SELECT "name" FROM "sqlite_schema" WHERE "type"='index' AND "tbl_name"='prosody' AND "name"='prosody_index';]] do + indices[row[1]] = true; end - end) - if indices["prosody_index"] then - if apply_changes then - local success = engine:transaction(function () - return assert(engine:execute([[DROP INDEX "prosody_index";]])); - end); - if not success then - module:log("error", "Failed to delete obsolete index \"prosody_index\""); - return false; - end - else - changes = true; + elseif params.driver == "PostgreSQL" then + for row in engine:select [[SELECT "indexname" FROM "pg_indexes" WHERE "tablename"='prosody' AND "indexname"='prosody_index';]] do + indices[row[1]] = true; end end + end) + if indices["prosody_index"] then + if apply_changes then + local success = engine:transaction(function () + return assert(engine:execute([[DROP INDEX "prosody_index";]])); + end); + if not success then + module:log("error", "Failed to delete obsolete index \"prosody_index\""); + return false; + end + else + changes = true; + end end + end return changes; end diff --git a/spec/core_storagemanager_spec.lua b/spec/core_storagemanager_spec.lua index f1adcd50..32a8d6f0 100644 --- a/spec/core_storagemanager_spec.lua +++ b/spec/core_storagemanager_spec.lua @@ -63,7 +63,7 @@ describe("storagemanager", function () end assert(hm.activate(test_host, {})); sm.initialize_host(test_host); - assert(mm.load(test_host, "storage_"..backend_config.storage)); + mm.load(test_host, "storage_"..backend_config.storage); describe("key-value stores", function () -- These tests rely on being executed in order, disable any order |