The *_url options now support 'auto'
This commit is contained in:
parent
f461bcb597
commit
94186a36d0
|
@ -68,12 +68,12 @@ process([], #request{method = 'GET', host = Host, raw_path = RawPath}) ->
|
|||
{<<"i18n">>, ejabberd_option:language(Host)},
|
||||
{<<"view_mode">>, <<"fullscreen">>}],
|
||||
Init2 =
|
||||
case gen_mod:get_module_opt(Host, ?MODULE, websocket_url) of
|
||||
case mod_host_meta:get_url(?MODULE, websocket, any, Host) of
|
||||
undefined -> Init;
|
||||
WSURL -> [{<<"websocket_url">>, WSURL} | Init]
|
||||
end,
|
||||
Init3 =
|
||||
case gen_mod:get_module_opt(Host, ?MODULE, bosh_service_url) of
|
||||
case mod_host_meta:get_url(?MODULE, bosh, any, Host) of
|
||||
undefined -> Init2;
|
||||
BoshURL -> [{<<"bosh_service_url">>, BoshURL} | Init2]
|
||||
end,
|
||||
|
@ -177,9 +177,9 @@ get_auto_file_url(Host, Filename, Default) ->
|
|||
%%----------------------------------------------------------------------
|
||||
|
||||
mod_opt_type(bosh_service_url) ->
|
||||
econf:either(undefined, econf:binary());
|
||||
econf:either(auto, econf:binary());
|
||||
mod_opt_type(websocket_url) ->
|
||||
econf:either(undefined, econf:binary());
|
||||
econf:either(auto, econf:binary());
|
||||
mod_opt_type(conversejs_resources) ->
|
||||
econf:either(undefined, econf:directory());
|
||||
mod_opt_type(conversejs_script) ->
|
||||
|
@ -190,8 +190,8 @@ mod_opt_type(default_domain) ->
|
|||
econf:binary().
|
||||
|
||||
mod_options(_) ->
|
||||
[{bosh_service_url, undefined},
|
||||
{websocket_url, undefined},
|
||||
[{bosh_service_url, auto},
|
||||
{websocket_url, auto},
|
||||
{default_domain, <<"@HOST@">>},
|
||||
{conversejs_resources, undefined},
|
||||
{conversejs_script, auto},
|
||||
|
@ -205,7 +205,9 @@ mod_doc() ->
|
|||
?T("To use this module, in addition to adding it to the 'modules' "
|
||||
"section, you must also enable it in 'listen' -> 'ejabberd_http' -> "
|
||||
"http://../listen-options/#request-handlers[request_handlers]."), "",
|
||||
?T("You must also setup either the option 'websocket_url' or 'bosh_service_url'."), "",
|
||||
?T("Make sure either 'mod_bosh' or 'ejabberd_http_ws' "
|
||||
"http://../listen-options/#request-handlers[request_handlers] "
|
||||
"are enabled."), "",
|
||||
?T("When 'conversejs_css' and 'conversejs_script' are 'auto', "
|
||||
"by default they point to the public Converse client.")
|
||||
],
|
||||
|
@ -224,13 +226,23 @@ mod_doc() ->
|
|||
" websocket_url: \"ws://example.org:5280/websocket\""],
|
||||
opts =>
|
||||
[{websocket_url,
|
||||
#{value => ?T("WebSocketURL"),
|
||||
#{value => ?T("auto | WebSocketURL"),
|
||||
desc =>
|
||||
?T("A WebSocket URL to which Converse.js can connect to.")}},
|
||||
?T("A WebSocket URL to which Converse can connect to. "
|
||||
"The keyword '@HOST@' is replaced with the real virtual "
|
||||
"host name. "
|
||||
"If set to 'auto', it will build the URL of the first "
|
||||
"configured WebSocket request handler. "
|
||||
"The default value is 'auto'.")}},
|
||||
{bosh_service_url,
|
||||
#{value => ?T("BoshURL"),
|
||||
#{value => ?T("auto | BoshURL"),
|
||||
desc =>
|
||||
?T("BOSH service URL to which Converse.js can connect to.")}},
|
||||
?T("BOSH service URL to which Converse can connect to. "
|
||||
"The keyword '@HOST@' is replaced with the real "
|
||||
"virtual host name. "
|
||||
"If set to 'auto', it will build the URL of the first "
|
||||
"configured BOSH request handler. "
|
||||
"The default value is 'auto'.")}},
|
||||
{default_domain,
|
||||
#{value => ?T("Domain"),
|
||||
desc =>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
-export([default_domain/1]).
|
||||
-export([websocket_url/1]).
|
||||
|
||||
-spec bosh_service_url(gen_mod:opts() | global | binary()) -> 'undefined' | binary().
|
||||
-spec bosh_service_url(gen_mod:opts() | global | binary()) -> 'auto' | binary().
|
||||
bosh_service_url(Opts) when is_map(Opts) ->
|
||||
gen_mod:get_opt(bosh_service_url, Opts);
|
||||
bosh_service_url(Host) ->
|
||||
|
@ -40,7 +40,7 @@ default_domain(Opts) when is_map(Opts) ->
|
|||
default_domain(Host) ->
|
||||
gen_mod:get_module_opt(Host, mod_conversejs, default_domain).
|
||||
|
||||
-spec websocket_url(gen_mod:opts() | global | binary()) -> 'undefined' | binary().
|
||||
-spec websocket_url(gen_mod:opts() | global | binary()) -> 'auto' | binary().
|
||||
websocket_url(Opts) when is_map(Opts) ->
|
||||
gen_mod:get_opt(websocket_url, Opts);
|
||||
websocket_url(Host) ->
|
||||
|
|
Loading…
Reference in New Issue