From b82b93f8f0c229e94a89469b0754bab0e28cd17c Mon Sep 17 00:00:00 2001 From: Evgeniy Khramtsov Date: Sat, 29 Apr 2017 11:39:40 +0300 Subject: Don't validate an option in ejabberd_config:get_option() functions The commit introduces the following changes: * Now there is no need to pass validating function in ejabberd_config:get_option() functions, because the configuration keeps already validated values. * New function ejabberd_config:get_option/1 is introduced * Function ejabberd_config:get_option/3 is deprecated. If the function is still called, the second argument (validating function) is simply ignored. * The second argument for ejabberd_config:get_option/2 is now a default value, not a validating function. --- src/ejabberd_captcha.erl | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'src/ejabberd_captcha.erl') diff --git a/src/ejabberd_captcha.erl b/src/ejabberd_captcha.erl index 3c42fa094..0a8dc0261 100644 --- a/src/ejabberd_captcha.erl +++ b/src/ejabberd_captcha.erl @@ -350,12 +350,7 @@ do_create_image(Key) -> end. get_prog_name() -> - case ejabberd_config:get_option( - captcha_cmd, - fun(FileName) -> - F = iolist_to_binary(FileName), - if F /= <<"">> -> F end - end) of + case ejabberd_config:get_option(captcha_cmd) of undefined -> ?DEBUG("The option captcha_cmd is not configured, " "but some module wants to use the CAPTCHA " @@ -367,10 +362,7 @@ get_prog_name() -> end. get_url(Str) -> - CaptchaHost = ejabberd_config:get_option( - captcha_host, - fun iolist_to_binary/1, - <<"">>), + CaptchaHost = ejabberd_config:get_option(captcha_host, <<"">>), case str:tokens(CaptchaHost, <<":">>) of [Host] -> <<"http://", Host/binary, "/captcha/", Str/binary>>; @@ -395,8 +387,7 @@ get_transfer_protocol(PortString) -> get_captcha_transfer_protocol(PortListeners). get_port_listeners(PortNumber) -> - AllListeners = ejabberd_config:get_option( - listen, fun ejabberd_listener:validate_cfg/1, []), + AllListeners = ejabberd_config:get_option(listen, []), lists:filter(fun (Listener) when is_list(Listener) -> case proplists:get_value(port, Listener) of PortNumber -> true; @@ -426,9 +417,7 @@ get_captcha_transfer_protocol([_ | Listeners]) -> is_limited(undefined) -> false; is_limited(Limiter) -> - case ejabberd_config:get_option( - captcha_limit, - fun(I) when is_integer(I), I > 0 -> I end) of + case ejabberd_config:get_option(captcha_limit) of undefined -> false; Int -> case catch gen_server:call(?MODULE, -- cgit v1.2.3