summaryrefslogtreecommitdiff
path: root/src/mod_http_api.erl
diff options
context:
space:
mode:
authorMickael Remond <mremond@process-one.net>2016-07-30 11:50:04 +0200
committerMickael Remond <mremond@process-one.net>2016-07-30 11:50:04 +0200
commitfb2603d3cdef98542f479764567b15c9c7777411 (patch)
tree9b8d3a125fe9c7028e2d16cdb1e372c6db9c9e05 /src/mod_http_api.erl
parentDo not crash on check when we do not have JID (diff)
Return 409 conflict error code on register if user already exists
Diffstat (limited to 'src/mod_http_api.erl')
-rw-r--r--src/mod_http_api.erl34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/mod_http_api.erl b/src/mod_http_api.erl
index ba3a14cf..f56a4766 100644
--- a/src/mod_http_api.erl
+++ b/src/mod_http_api.erl
@@ -444,22 +444,24 @@ ejabberd_command(Auth, Cmd, Args, Version, IP) ->
format_command_result(Cmd, Auth, Result, Version) ->
{_, ResultFormat} = ejabberd_commands:get_command_format(Cmd, Auth, Version),
case {ResultFormat, Result} of
- {{_, rescode}, V} when V == true; V == ok ->
- {200, 0};
- {{_, rescode}, _} ->
- {200, 1};
- {{_, restuple}, {V1, Text1}} when V1 == true; V1 == ok ->
- {200, iolist_to_binary(Text1)};
- {{_, restuple}, {_, Text2}} ->
- {500, iolist_to_binary(Text2)};
- {{_, {list, _}}, _V} ->
- {_, L} = format_result(Result, ResultFormat),
- {200, L};
- {{_, {tuple, _}}, _V} ->
- {_, T} = format_result(Result, ResultFormat),
- {200, T};
- _ ->
- {200, {[format_result(Result, ResultFormat)]}}
+ {{_, rescode}, V} when V == true; V == ok ->
+ {200, 0};
+ {{_, rescode}, _} ->
+ {200, 1};
+ {{_, restuple}, {V, Text}} when V == true; V == ok ->
+ {200, iolist_to_binary(Text)};
+ {{_, restuple}, {V, Text}} when V == conflict ->
+ {409, iolist_to_binary(Text)};
+ {{_, restuple}, {_, Text2}} ->
+ {500, iolist_to_binary(Text2)};
+ {{_, {list, _}}, _V} ->
+ {_, L} = format_result(Result, ResultFormat),
+ {200, L};
+ {{_, {tuple, _}}, _V} ->
+ {_, T} = format_result(Result, ResultFormat),
+ {200, T};
+ _ ->
+ {200, {[format_result(Result, ResultFormat)]}}
end.
format_result(Atom, {Name, atom}) ->