25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

Accept more types of ejabberdctl commands arguments as JSON-encoded

This commit is contained in:
Alexey Shchepin 2021-12-20 09:29:42 +03:00
parent 42bdb501ca
commit 536beedeb6
2 changed files with 6 additions and 1 deletions

View File

@ -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),

View File

@ -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").