mod_groups_internal/mod_groups_internal.lua
changeset 4396 e5792ca1d704
parent 4393 6cfa313cd524
child 4403 846b7af5588c
equal deleted inserted replaced
4395:679a0c9d365d 4396:e5792ca1d704
     7 
     7 
     8 local group_info_store = module:open_store("group_info");
     8 local group_info_store = module:open_store("group_info");
     9 local group_members_store = module:open_store("groups");
     9 local group_members_store = module:open_store("groups");
    10 local group_memberships = module:open_store("groups", "map");
    10 local group_memberships = module:open_store("groups", "map");
    11 
    11 
    12 local muc_host_name = module:get_option("groups_muc_host", "chats."..host);
    12 local muc_host_name = module:get_option("groups_muc_host", "groups."..host);
    13 local muc_host = nil;
    13 local muc_host = nil;
    14 
    14 
    15 local is_contact_subscribed = rostermanager.is_contact_subscribed;
    15 local is_contact_subscribed = rostermanager.is_contact_subscribed;
    16 
    16 
    17 -- Make a *one-way* subscription. User will see when contact is online,
    17 -- Make a *one-way* subscription. User will see when contact is online,
   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 handle_server_started()
       
   248 	if not muc_host_name then
       
   249 		module:log("info", "MUC management disabled (groups_muc_host set to nil)")
       
   250 		return
       
   251 	end
       
   252 
   248 	local target_module = modulemanager.get_module(muc_host_name, "muc")
   253 	local target_module = modulemanager.get_module(muc_host_name, "muc")
   249 	if not target_module then
   254 	if not target_module then
   250 		module:log("error", "host %s is not a MUC host -- group management will not work correctly", muc_host_name)
   255 		module:log("error", "host %s is not a MUC host -- group management will not work correctly; check your groups_muc_host setting!", muc_host_name)
   251 	else
   256 	else
   252 		module:log("debug", "found MUC host")
   257 		module:log("debug", "found MUC host at %s", muc_host_name)
   253 		muc_host = target_module;
   258 		muc_host = target_module;
   254 	end
   259 	end
   255 end
   260 end
   256 
   261 
   257 module:hook_global("server-started", handle_server_started)
   262 module:hook_global("server-started", handle_server_started)