Changeset

13783:833fa5d08d13

Merge 13.0->trunk
author Kim Alvefur <zash@zash.se>
date Sat, 22 Mar 2025 11:56:23 +0100
parents 13779:c3a02b00cab2 (current diff) 13782:4cfabfbb0691 (diff)
children 13787:3e72cdca6beb
files
diffstat 3 files changed, 31 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/core/usermanager.lua	Mon Mar 17 16:49:22 2025 +0000
+++ b/core/usermanager.lua	Sat Mar 22 11:56:23 2025 +0100
@@ -307,7 +307,8 @@
 	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)
--- a/plugins/mod_storage_sql.lua	Mon Mar 17 16:49:22 2025 +0000
+++ b/plugins/mod_storage_sql.lua	Sat Mar 22 11:56:23 2025 +0100
@@ -866,38 +866,38 @@
 		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
 
--- a/spec/core_storagemanager_spec.lua	Mon Mar 17 16:49:22 2025 +0000
+++ b/spec/core_storagemanager_spec.lua	Sat Mar 22 11:56:23 2025 +0100
@@ -63,7 +63,7 @@
 			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