1
0
Fork 0
mirror of https://github.com/processone/ejabberd synced 2025-10-03 17:59:31 +02:00

Raise api hook right before performing the call

This commit is contained in:
Christophe Romain 2019-05-07 11:46:04 +02:00
parent 4dc8549738
commit a6f7d7ce23

View file

@ -100,6 +100,7 @@ request(Server, Method, Path, Params, Mime, Data) ->
{URI, Hdrs} {URI, Hdrs}
end, end,
Begin = os:timestamp(), Begin = os:timestamp(),
ejabberd_hooks:run(backend_api_call, Server, [Server, Method, Path]),
Result = try httpc:request(Method, Req, HttpOpts, [{body_format, binary}]) of Result = try httpc:request(Method, Req, HttpOpts, [{body_format, binary}]) of
{ok, {{_, Code, _}, RetHdrs, Body}} -> {ok, {{_, Code, _}, RetHdrs, Body}} ->
try decode_json(Body) of try decode_json(Body) of
@ -118,7 +119,6 @@ request(Server, Method, Path, Params, Mime, Data) ->
exit:Reason -> exit:Reason ->
{error, {http_error, {error, Reason}}} {error, {http_error, {error, Reason}}}
end, end,
ejabberd_hooks:run(backend_api_call, Server, [Server, Method, Path]),
case Result of case Result of
{error, {http_error, {error, timeout}}} -> {error, {http_error, {error, timeout}}} ->
ejabberd_hooks:run(backend_api_timeout, Server, ejabberd_hooks:run(backend_api_timeout, Server,