aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Shchepin <alexey@process-one.net>2021-12-20 09:29:42 +0300
committerAlexey Shchepin <alexey@process-one.net>2021-12-20 09:42:02 +0300
commit536beedeb66e6a54ea3631e09a441395f4b11527 (patch)
treef57e6926c49115a69145c631938a403e2ca97819
parentmod_stun_disco: Fix parsing of IPv6 listeners (diff)
Accept more types of ejabberdctl commands arguments as JSON-encoded
-rw-r--r--src/ejabberd_ctl.erl6
-rw-r--r--src/mod_http_api.erl1
2 files changed, 6 insertions, 1 deletions
diff --git a/src/ejabberd_ctl.erl b/src/ejabberd_ctl.erl
index 354e5ba2f..77595cd54 100644
--- a/src/ejabberd_ctl.erl
+++ b/src/ejabberd_ctl.erl
@@ -378,7 +378,11 @@ format_arg("", string) ->
format_arg(Arg, string) ->
NumChars = integer_to_list(length(Arg)),
Parse = "~" ++ NumChars ++ "c",
- format_arg2(Arg, Parse).
+ format_arg2(Arg, Parse);
+format_arg(Arg, Format) ->
+ S = unicode:characters_to_binary(Arg, utf8),
+ JSON = jiffy:decode(S),
+ mod_http_api:format_arg(JSON, Format).
format_arg2(Arg, Parse)->
{ok, [Arg2], _RemainingArguments} = io_lib:fread(Parse, Arg),
diff --git a/src/mod_http_api.erl b/src/mod_http_api.erl
index 427833584..023df39ca 100644
--- a/src/mod_http_api.erl
+++ b/src/mod_http_api.erl
@@ -30,6 +30,7 @@
-behaviour(gen_mod).
-export([start/2, stop/1, reload/3, process/2, depends/2,
+ format_arg/2,
mod_options/1, mod_doc/0]).
-include_lib("xmpp/include/xmpp.hrl").