aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/usermanager.lua3
-rw-r--r--plugins/mod_storage_sql.lua56
-rw-r--r--spec/core_storagemanager_spec.lua2
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