comparison mod_groups_internal/mod_groups_internal.lua @ 4417:7e379ccb8ed6

mod_groups_internal: make robust against module reloads
author Jonas Schäfer <jonas@wielicki.name>
date Sun, 31 Jan 2021 12:14:21 +0100
parents c7424b96c75e
children 8c31d4b872c3
comparison
equal deleted inserted replaced
4416:dd3bfe8f182e 4417:7e379ccb8ed6
242 -- Returns iterator over group ids 242 -- Returns iterator over group ids
243 function groups() 243 function groups()
244 return group_info_store:users(); 244 return group_info_store:users();
245 end 245 end
246 246
247 local function handle_server_started() 247 local function setup()
248 if not muc_host_name then 248 if not muc_host_name then
249 module:log("info", "MUC management disabled (groups_muc_host set to nil)"); 249 module:log("info", "MUC management disabled (groups_muc_host set to nil)");
250 return; 250 return;
251 end 251 end
252 252
257 module:log("debug", "found MUC host at %s", muc_host_name); 257 module:log("debug", "found MUC host at %s", muc_host_name);
258 muc_host = target_module; 258 muc_host = target_module;
259 end 259 end
260 end 260 end
261 261
262 module:hook_global("server-started", handle_server_started); 262 if prosody.start_time then -- server already started
263 setup();
264 else
265 module:hook_global("server-started", setup);
266 end