Skip to content

Commit

Permalink
Merge pull request #3697 from esl/without-mongoose-commands
Browse files Browse the repository at this point in the history
Do not use mongoose_commands in the Client REST API
  • Loading branch information
Premwoik authored Jul 1, 2022
2 parents bbdc781 + 77ca788 commit ffc778d
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 447 deletions.
9 changes: 0 additions & 9 deletions src/mod_commands.erl
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ commands() ->
{module, ?MODULE},
{function, list_contacts},
{action, read},
{security_policy, [user]},
{args, [{caller, binary}]},
{result, []}
],
Expand All @@ -136,7 +135,6 @@ commands() ->
{module, ?MODULE},
{function, add_contact},
{action, create},
{security_policy, [user]},
{args, [{caller, binary}, {jid, binary}]},
{result, ok}
],
Expand All @@ -147,7 +145,6 @@ commands() ->
{module, ?MODULE},
{function, subscription},
{action, update},
{security_policy, [user]},
{identifiers, [caller, jid]},
% caller has to be in identifiers, otherwise it breaks admin rest api
{args, [{caller, binary}, {jid, binary}, {action, binary}]},
Expand All @@ -172,7 +169,6 @@ commands() ->
{module, ?MODULE},
{function, delete_contact},
{action, delete},
{security_policy, [user]},
{args, [{caller, binary}, {jid, binary}]},
{result, ok}
],
Expand All @@ -184,7 +180,6 @@ commands() ->
{module, ?MODULE},
{function, delete_contacts},
{action, delete},
{security_policy, [user]},
{args, [{caller, binary}, {jids, [binary]}]},
{result, []}
],
Expand All @@ -195,7 +190,6 @@ commands() ->
{module, ?MODULE},
{function, send_message},
{action, create},
{security_policy, [user]},
{args, [{caller, binary}, {to, binary}, {body, binary}]},
{result, ok}
],
Expand All @@ -216,7 +210,6 @@ commands() ->
{module, ?MODULE},
{function, get_recent_messages},
{action, read},
{security_policy, [user]},
{args, [{caller, binary}]},
{optargs, [{before, integer, 0}, {limit, integer, 100}]},
{result, []}
Expand All @@ -228,7 +221,6 @@ commands() ->
{module, ?MODULE},
{function, get_recent_messages},
{action, read},
{security_policy, [user]},
{args, [{caller, binary}, {with, binary}]},
{optargs, [{before, integer, 0}, {limit, integer, 100}]},
{result, []}
Expand All @@ -240,7 +232,6 @@ commands() ->
{module, ?MODULE},
{function, change_user_password},
{action, update},
{security_policy, [user]},
{identifiers, [host, user]},
{args, [{host, binary}, {user, binary}, {newpass, binary}]},
{result, ok}
Expand Down
169 changes: 0 additions & 169 deletions src/mongoose_api_client.erl

This file was deleted.

10 changes: 0 additions & 10 deletions src/mongoose_api_common.erl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@

%% API
-export([create_admin_url_path/1,
create_user_url_path/1,
action_to_method/1,
method_to_action/1,
parse_request_body/1,
Expand Down Expand Up @@ -102,13 +101,6 @@ create_admin_url_path_iodata(Command) ->
["/", mongoose_commands:category(Command),
maybe_add_bindings(Command, admin), maybe_add_subcategory(Command)].

-spec create_user_url_path(mongoose_commands:t()) -> ejabberd_cowboy:path().
create_user_url_path(Command) ->
iolist_to_binary(create_user_url_path_iodata(Command)).

create_user_url_path_iodata(Command) ->
["/", mongoose_commands:category(Command), maybe_add_bindings(Command, user)].

-spec process_request(Method :: method(),
Command :: mongoose_commands:t(),
Req :: cowboy_req:req() | {list(), cowboy_req:req()},
Expand Down Expand Up @@ -309,8 +301,6 @@ add_bindings(Args, Entity) ->
[add_bind(A, Entity) || A <- Args].

%% skip "caller" arg for frontend command
add_bind({caller, _}, user) ->
"";
add_bind({ArgName, _}, _Entity) ->
lists:flatten(["/:", atom_to_list(ArgName)]);
add_bind(Other, _) ->
Expand Down
Loading

0 comments on commit ffc778d

Please sign in to comment.