changeset 2451:56bab95e57f0

mod_candy: If no room list is set, try to find a MUC domain and guess a room name of 'candy'
author Kim Alvefur <zash@zash.se>
date Fri, 20 Jan 2017 01:25:11 +0100
parents 36ffe9d11132
children 7d86018a6394
files mod_candy/README.markdown mod_candy/mod_candy.lua
diffstat 2 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_candy/README.markdown	Fri Jan 20 01:24:32 2017 +0100
+++ b/mod_candy/README.markdown	Fri Jan 20 01:25:11 2017 +0100
@@ -32,7 +32,9 @@
 
 You can configure what rooms to join using either `candy_rooms` (an
 array) or [mod\_default\_bookmarks]. By default, Candy will attempt to
-join rooms that the current user has bookmarked. If there are no rooms
+join rooms that the current user has bookmarked.
+If `candy_rooms` is not set, mod\_candy will attempt to find a MUC
+component and join a room called "candy" there.  If there are no rooms
 to join, then Candy will show an emtpy screen.
 
 Compatibility
--- a/mod_candy/mod_candy.lua	Fri Jan 20 01:24:32 2017 +0100
+++ b/mod_candy/mod_candy.lua	Fri Jan 20 01:25:11 2017 +0100
@@ -2,6 +2,7 @@
 -- Copyright (C) 2013-2017 Kim Alvefur
 
 local json_encode = require"util.json".encode;
+local get_host_children = require "core.hostmanager".get_children;
 local is_module_loaded = require "core.modulemanager".is_loaded;
 
 local serve = module:depends"http_files".serve;
@@ -13,6 +14,13 @@
 		-- Configured room list, if any
 		return candy_rooms;
 	end
+	for subdomain in pairs(get_host_children(module.host)) do
+		-- Attempt autodetect a MUC host
+		if is_module_loaded(subdomain, "muc") then
+			return { "candy@" .. subdomain }
+		end
+	end
+	-- Autojoin bookmarks then?
 	-- Check out mod_default_bookmarks
 	return true;
 end