aboutsummaryrefslogtreecommitdiff
path: root/src/ejabberd_commands.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_commands.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_commands.erl')
-rw-r--r--src/ejabberd_commands.erl15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/ejabberd_commands.erl b/src/ejabberd_commands.erl
index df0ce9123..3a6f6db1f 100644
--- a/src/ejabberd_commands.erl
+++ b/src/ejabberd_commands.erl
@@ -211,6 +211,7 @@
-author('badlop@process-one.net').
-behaviour(gen_server).
+-behaviour(ejabberd_config).
-define(DEFAULT_VERSION, 1000000).
@@ -822,10 +823,7 @@ get_access_commands(AccessCommands, _Version) ->
get_exposed_commands() ->
get_exposed_commands(?DEFAULT_VERSION).
get_exposed_commands(Version) ->
- Opts0 = ejabberd_config:get_option(
- commands,
- fun(V) when is_list(V) -> V end,
- []),
+ Opts0 = ejabberd_config:get_option(commands, []),
Opts = lists:map(fun(V) when is_tuple(V) -> [V]; (V) -> V end, Opts0),
CommandsList = list_commands_policy(Version),
OpenCmds = [N || {N, _, _, open} <- CommandsList],
@@ -876,10 +874,7 @@ is_admin(Name, Auth, Extra) ->
_ ->
{Extra, global}
end,
- AdminAccess = ejabberd_config:get_option(
- commands_admin_access,
- fun(V) -> V end,
- none),
+ AdminAccess = ejabberd_config:get_option(commands_admin_access, none),
case acl:access_matches(AdminAccess, ACLInfo, Server) of
allow ->
case catch check_auth(get_command_definition(Name), Auth) of
@@ -893,9 +888,7 @@ is_admin(Name, Auth, Extra) ->
permission_addon() ->
[{<<"'commands' option compatibility shim">>,
{[],
- [{access, ejabberd_config:get_option(commands_admin_access,
- fun(V) -> V end,
- none)}],
+ [{access, ejabberd_config:get_option(commands_admin_access, none)}],
{get_exposed_commands(), []}}}].
opt_type(commands_admin_access) -> fun acl:access_rules_validator/1;