aboutsummaryrefslogtreecommitdiff
path: root/src/ejabberd_captcha.erl
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-04-29 11:39:40 +0300
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-04-29 11:39:40 +0300
commitb82b93f8f0c229e94a89469b0754bab0e28cd17c (patch)
tree56f5c7a25aa19254b4f30b1cf33fc34dcbadcbb7 /src/ejabberd_captcha.erl
parentDon't re-define validation functions in multiple places (diff)
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.
Diffstat (limited to 'src/ejabberd_captcha.erl')
-rw-r--r--src/ejabberd_captcha.erl19
1 files changed, 4 insertions, 15 deletions
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,