diff mod_default_bookmarks/mod_default_bookmarks.lua @ 4857:3f6711c1c66a

mod_default_bookmarks: Use whichever of mod_bookmarks and mod_bookmarks2 is enabled
author Kim Alvefur <zash@zash.se>
date Sat, 08 Jan 2022 00:05:45 +0100
parents b3f0f82af5a2
children 727f147aac4d
line wrap: on
line diff
--- a/mod_default_bookmarks/mod_default_bookmarks.lua	Sat Jan 08 00:01:29 2022 +0100
+++ b/mod_default_bookmarks/mod_default_bookmarks.lua	Sat Jan 08 00:05:45 2022 +0100
@@ -13,11 +13,14 @@
 local jid_split = require "util.jid".split
 
 -- COMPAT w/trunk
-local is_on_trunk = false;
+local mod_bookmarks_available = false;
 local mm = require "core.modulemanager";
 if mm.get_modules_for_host then
-	if mm.get_modules_for_host(module.host):contains("bookmarks") then
-		is_on_trunk = true;
+	local host_modules = mm.get_modules_for_host(module.host);
+	if host_modules:contains("bookmarks") then
+		mod_bookmarks_available = "bookmarks";
+	elseif host_modules:contains("bookmarks2") then
+		mod_bookmarks_available = "bookmarks2";
 	end
 end
 
@@ -48,8 +51,8 @@
 	return reply;
 end
 
-if is_on_trunk then
-	local mod_bookmarks = module:depends "bookmarks";
+if mod_bookmarks_available then
+	local mod_bookmarks = module:depends(mod_bookmarks_available);
 	local function on_bookmarks_empty(event)
 		local session = event.session;
 		if mod_bookmarks.publish_to_pep then