fix(mod_s3_upload): type specs, contract adherance

This commit is contained in:
Roman Hargrave 2022-09-08 21:46:44 -07:00
parent 5168c145ff
commit ffd2607ada
No known key found for this signature in database
GPG Key ID: E7679B92360E753A
1 changed files with 11 additions and 10 deletions

View File

@ -119,7 +119,7 @@ mod_opt_type(access) ->
-spec mod_options( -spec mod_options(
Host :: binary() Host :: binary()
) -> ) ->
Options :: [{atom, any()}]. Options :: [{atom(), term()} | atom()].
% %
mod_options(Host) -> mod_options(Host) ->
[{access_key_id, undefined}, [{access_key_id, undefined},
@ -198,7 +198,7 @@ depends(_Host, _Opts) ->
-spec init( -spec init(
Params :: list() Params :: list()
) -> ) ->
Result :: {ok, gen_mod:opts()}. Result :: {ok, #params{}}.
% %
init([ServerHost, Opts]) -> init([ServerHost, Opts]) ->
Params = build_service_params(ServerHost, Opts), Params = build_service_params(ServerHost, Opts),
@ -207,9 +207,9 @@ init([ServerHost, Opts]) ->
-spec handle_info( -spec handle_info(
Message :: any(), Message :: any(),
State :: gen_mod:opts() State :: #params{}
) -> ) ->
Result :: {noreply, gen_mod:opts()}. Result :: {noreply, #params{}}.
% receive non-standard (gen_server) messages % receive non-standard (gen_server) messages
handle_info({route, #iq{lang = Lang} = Packet}, Opts) -> handle_info({route, #iq{lang = Lang} = Packet}, Opts) ->
try xmpp:decode_els(Packet) of try xmpp:decode_els(Packet) of
@ -229,9 +229,9 @@ handle_info(Request, Opts) ->
-spec handle_call( -spec handle_call(
Request:: any(), Request:: any(),
Sender :: gen_server:from(), Sender :: gen_server:from(),
State :: gen_mod:opts() State :: #params{}
) -> ) ->
Result :: {_, gen_mod:opts()}. Result :: {noreply, #params{}}.
% respond to $gen_call messages % respond to $gen_call messages
handle_call(Request, Sender, Opts) -> handle_call(Request, Sender, Opts) ->
?WARNING_MSG("Unexpected call from ~p: ~p", [Sender, Request]), ?WARNING_MSG("Unexpected call from ~p: ~p", [Sender, Request]),
@ -239,15 +239,15 @@ handle_call(Request, Sender, Opts) ->
-spec handle_cast( -spec handle_cast(
Request :: any(), Request :: any(),
State :: gen_mod:opts() State :: #params{}
) -> ) ->
Result :: {_, gen_mod:opts()}. Result :: {noreply, #params{}}.
% receive $gen_cast messages % receive $gen_cast messages
handle_cast({reload, ServerHost, NewOpts}, OldOpts) -> handle_cast({reload, ServerHost, NewOpts}, OldOpts) ->
update_routes(ServerHost, update_routes(ServerHost,
OldOpts#params.service_jids, OldOpts#params.service_jids,
NewOpts#params.service_jids), NewOpts#params.service_jids),
{ok, NewOpts}; {noreply, NewOpts};
handle_cast(Request, Opts) -> handle_cast(Request, Opts) ->
?WARNING_MSG("Unexpected cast: ~p", [Request]), ?WARNING_MSG("Unexpected cast: ~p", [Request]),
{noreply, Opts}. {noreply, Opts}.
@ -279,9 +279,10 @@ update_routes(ServerHost, OldJIDs, NewJIDs) ->
% XEP-0363 v1.1.0 Ex. 4. % XEP-0363 v1.1.0 Ex. 4.
handle_iq(#iq{type = get, handle_iq(#iq{type = get,
lang = Lang, lang = Lang,
to = Host, to = HostJID,
sub_els = [#disco_info{}]} = IQ, sub_els = [#disco_info{}]} = IQ,
#params{max_size = MaxSize, service_name = ServiceName}) -> #params{max_size = MaxSize, service_name = ServiceName}) ->
Host = jid:encode(HostJID),
% collect additional discovery entries, if any. % collect additional discovery entries, if any.
Advice = ejabberd_hooks:run_fold(disco_info, Host, [], Advice = ejabberd_hooks:run_fold(disco_info, Host, [],
[Host, ?MODULE, <<"">>, Lang]), [Host, ?MODULE, <<"">>, Lang]),