Comparison

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
comparison
equal deleted inserted replaced
3362:af085e8b9d48 3363:2681f74750b2
2 -- Copyright (C) 2017 Kim Alvefur 2 -- Copyright (C) 2017 Kim Alvefur
3 3
4 local json_encode = require"util.json".encode; 4 local json_encode = require"util.json".encode;
5 5
6 module:depends"http"; 6 module:depends"http";
7 module:depends"bosh"; 7
8 local has_bosh = pcall(function ()
9 module:depends"bosh";
10 end);
8 11
9 local has_ws = pcall(function () 12 local has_ws = pcall(function ()
10 module:depends("websocket"); 13 module:depends("websocket");
11 end); 14 end);
12 15
56 local user_options = module:get_option("conversejs_options"); 59 local user_options = module:get_option("conversejs_options");
57 60
58 local function get_converse_options() 61 local function get_converse_options()
59 local allow_registration = module:get_option_boolean("allow_registration", false); 62 local allow_registration = module:get_option_boolean("allow_registration", false);
60 local converse_options = { 63 local converse_options = {
61 bosh_service_url = module:http_url("bosh","/http-bind"); 64 bosh_service_url = has_bosh and module:http_url("bosh","/http-bind") or nil;
62 websocket_url = has_ws and module:http_url("websocket","xmpp-websocket"):gsub("^http", "ws") or nil; 65 websocket_url = has_ws and module:http_url("websocket","xmpp-websocket"):gsub("^http", "ws") or nil;
63 authentication = module:get_option_string("authentication") == "anonymous" and "anonymous" or "login"; 66 authentication = module:get_option_string("authentication") == "anonymous" and "anonymous" or "login";
64 jid = module.host; 67 jid = module.host;
65 default_domain = module.host; 68 default_domain = module.host;
66 domain_placeholder = module.host; 69 domain_placeholder = module.host;