comparison 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
comparison
equal deleted inserted replaced
4856:b3f0f82af5a2 4857:3f6711c1c66a
11 local st = require "util.stanza" 11 local st = require "util.stanza"
12 local dm_load = require "util.datamanager".load 12 local dm_load = require "util.datamanager".load
13 local jid_split = require "util.jid".split 13 local jid_split = require "util.jid".split
14 14
15 -- COMPAT w/trunk 15 -- COMPAT w/trunk
16 local is_on_trunk = false; 16 local mod_bookmarks_available = false;
17 local mm = require "core.modulemanager"; 17 local mm = require "core.modulemanager";
18 if mm.get_modules_for_host then 18 if mm.get_modules_for_host then
19 if mm.get_modules_for_host(module.host):contains("bookmarks") then 19 local host_modules = mm.get_modules_for_host(module.host);
20 is_on_trunk = true; 20 if host_modules:contains("bookmarks") then
21 mod_bookmarks_available = "bookmarks";
22 elseif host_modules:contains("bookmarks2") then
23 mod_bookmarks_available = "bookmarks2";
21 end 24 end
22 end 25 end
23 26
24 local function get_default_bookmarks(nickname) 27 local function get_default_bookmarks(nickname)
25 local bookmarks = module:get_option("default_bookmarks"); 28 local bookmarks = module:get_option("default_bookmarks");
46 reply:up(); 49 reply:up();
47 end 50 end
48 return reply; 51 return reply;
49 end 52 end
50 53
51 if is_on_trunk then 54 if mod_bookmarks_available then
52 local mod_bookmarks = module:depends "bookmarks"; 55 local mod_bookmarks = module:depends(mod_bookmarks_available);
53 local function on_bookmarks_empty(event) 56 local function on_bookmarks_empty(event)
54 local session = event.session; 57 local session = event.session;
55 if mod_bookmarks.publish_to_pep then 58 if mod_bookmarks.publish_to_pep then
56 local bookmarks = get_default_bookmarks(session.username); 59 local bookmarks = get_default_bookmarks(session.username);
57 if bookmarks then 60 if bookmarks then