Diff

mod_conversejs/mod_conversejs.lua @ 3363:2681f74750b2

mod_conversejs: Weaken dependency on mod_bosh In trunk after e4c09e335bd9 it will now be possible to set modules_disabled = { "bosh" } to prevent it from being loaded.
author Kim Alvefur <zash@zash.se>
date Fri, 26 Oct 2018 20:07:16 +0200
parent 3348:f753cf4f7224
child 3492:f59334da6df9
line wrap: on
line diff
--- a/mod_conversejs/mod_conversejs.lua	Thu Oct 25 22:41:13 2018 +0200
+++ b/mod_conversejs/mod_conversejs.lua	Fri Oct 26 20:07:16 2018 +0200
@@ -4,7 +4,10 @@
 local json_encode = require"util.json".encode;
 
 module:depends"http";
-module:depends"bosh";
+
+local has_bosh = pcall(function ()
+	module:depends"bosh";
+end);
 
 local has_ws = pcall(function ()
 	module:depends("websocket");
@@ -58,7 +61,7 @@
 local function get_converse_options()
 	local allow_registration = module:get_option_boolean("allow_registration", false);
 	local converse_options = {
-		bosh_service_url = module:http_url("bosh","/http-bind");
+		bosh_service_url = has_bosh and module:http_url("bosh","/http-bind") or nil;
 		websocket_url = has_ws and module:http_url("websocket","xmpp-websocket"):gsub("^http", "ws") or nil;
 		authentication = module:get_option_string("authentication") == "anonymous" and "anonymous" or "login";
 		jid = module.host;