|
|
@@ -52,7 +52,7 @@ paths() -> ["/mqtt/delayed", "/mqtt/delayed/messages", "/mqtt/delayed/messages/:
|
|
|
|
|
|
schema("/mqtt/delayed") ->
|
|
|
#{
|
|
|
- operationId => status,
|
|
|
+ 'operationId' => status,
|
|
|
get => #{
|
|
|
tags => [<<"mqtt">>],
|
|
|
description => <<"Get delayed status">>,
|
|
|
@@ -64,25 +64,28 @@ schema("/mqtt/delayed") ->
|
|
|
put => #{
|
|
|
tags => [<<"mqtt">>],
|
|
|
description => <<"Enable or disable delayed, set max delayed messages">>,
|
|
|
- requestBody => ref(emqx_modules_schema, "delayed"),
|
|
|
+ 'requestBody' => ref(emqx_modules_schema, "delayed"),
|
|
|
responses => #{
|
|
|
200 => mk(ref(emqx_modules_schema, "delayed"),
|
|
|
#{desc => <<"Enable or disable delayed successfully">>}),
|
|
|
- 400 => emqx_dashboard_swagger:error_codes([?BAD_REQUEST], <<"Max limit illegality">>)
|
|
|
+ 400 => emqx_dashboard_swagger:error_codes( [?BAD_REQUEST]
|
|
|
+ , <<"Max limit illegality">>)
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
schema("/mqtt/delayed/messages/:msgid") ->
|
|
|
- #{operationId => delayed_message,
|
|
|
+ #{'operationId' => delayed_message,
|
|
|
get => #{
|
|
|
tags => [<<"mqtt">>],
|
|
|
description => <<"Get delayed message">>,
|
|
|
parameters => [{msgid, mk(binary(), #{in => path, desc => <<"delay message ID">>})}],
|
|
|
responses => #{
|
|
|
200 => ref("message_without_payload"),
|
|
|
- 400 => emqx_dashboard_swagger:error_codes([?MESSAGE_ID_SCHEMA_ERROR], <<"Bad MsgId format">>),
|
|
|
- 404 => emqx_dashboard_swagger:error_codes([?MESSAGE_ID_NOT_FOUND], <<"MsgId not found">>)
|
|
|
+ 400 => emqx_dashboard_swagger:error_codes( [?MESSAGE_ID_SCHEMA_ERROR]
|
|
|
+ , <<"Bad MsgId format">>),
|
|
|
+ 404 => emqx_dashboard_swagger:error_codes( [?MESSAGE_ID_NOT_FOUND]
|
|
|
+ , <<"MsgId not found">>)
|
|
|
}
|
|
|
},
|
|
|
delete => #{
|
|
|
@@ -91,14 +94,16 @@ schema("/mqtt/delayed/messages/:msgid") ->
|
|
|
parameters => [{msgid, mk(binary(), #{in => path, desc => <<"delay message ID">>})}],
|
|
|
responses => #{
|
|
|
204 => <<"Delete delayed message success">>,
|
|
|
- 400 => emqx_dashboard_swagger:error_codes([?MESSAGE_ID_SCHEMA_ERROR], <<"Bad MsgId format">>),
|
|
|
- 404 => emqx_dashboard_swagger:error_codes([?MESSAGE_ID_NOT_FOUND], <<"MsgId not found">>)
|
|
|
+ 400 => emqx_dashboard_swagger:error_codes( [?MESSAGE_ID_SCHEMA_ERROR]
|
|
|
+ , <<"Bad MsgId format">>),
|
|
|
+ 404 => emqx_dashboard_swagger:error_codes( [?MESSAGE_ID_NOT_FOUND]
|
|
|
+ , <<"MsgId not found">>)
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
schema("/mqtt/delayed/messages") ->
|
|
|
#{
|
|
|
- operationId => delayed_messages,
|
|
|
+ 'operationId' => delayed_messages,
|
|
|
get => #{
|
|
|
tags => [<<"mqtt">>],
|
|
|
description => <<"List delayed messages">>,
|
|
|
@@ -130,7 +135,8 @@ fields("message_without_payload") ->
|
|
|
{from_username, mk(binary(), #{desc => <<"From Username">>})}
|
|
|
];
|
|
|
fields("message") ->
|
|
|
- PayloadDesc = io_lib:format("Payload, base64 encode. Payload will be ~p if length large than ~p",
|
|
|
+ PayloadDesc = io_lib:format(
|
|
|
+ "Payload, base64 encode. Payload will be ~p if length large than ~p",
|
|
|
[?PAYLOAD_TOO_LARGE, ?MAX_PAYLOAD_LENGTH]),
|
|
|
fields("message_without_payload") ++
|
|
|
[{payload, mk(binary(), #{desc => iolist_to_binary(PayloadDesc)})}].
|
|
|
@@ -233,9 +239,11 @@ update_config_(Node, Config) ->
|
|
|
rpc_call(Node, ?MODULE, ?FUNCTION_NAME, [Node, Config]).
|
|
|
|
|
|
generate_http_code_map(id_schema_error, Id) ->
|
|
|
- #{code => ?MESSAGE_ID_SCHEMA_ERROR, message => iolist_to_binary(io_lib:format("Message ID ~p schema error", [Id]))};
|
|
|
+ #{code => ?MESSAGE_ID_SCHEMA_ERROR, message =>
|
|
|
+ iolist_to_binary(io_lib:format("Message ID ~p schema error", [Id]))};
|
|
|
generate_http_code_map(not_found, Id) ->
|
|
|
- #{code => ?MESSAGE_ID_NOT_FOUND, message => iolist_to_binary(io_lib:format("Message ID ~p not found", [Id]))}.
|
|
|
+ #{code => ?MESSAGE_ID_NOT_FOUND, message =>
|
|
|
+ iolist_to_binary(io_lib:format("Message ID ~p not found", [Id]))}.
|
|
|
|
|
|
rpc_call(Node, Module, Fun, Args) ->
|
|
|
case rpc:call(Node, Module, Fun, Args) of
|