Fix specs and other errores detected by Dialyzer

This commit is contained in:
Badlop 2022-08-12 17:57:07 +02:00
parent 6adfc2cec5
commit 35d05f2925
4 changed files with 9 additions and 9 deletions

View File

@ -126,7 +126,7 @@ try_register(LUser, LServer, Password) ->
false -> Password
end,
case make_req(post, <<"register">>, LUser, LServer, PasswordFinal) of
{ok, created} -> {cache, {ok, Password}};
{ok, <<"created">>} -> {cache, {ok, Password}};
{error, conflict} -> {nocache, {error, exists}};
_Error -> {nocache, {error, not_allowed}}
end.
@ -220,7 +220,7 @@ make_req(Method, Path, LUser, LServer, Password) ->
<<"400">> -> {error, RespBody};
<<"503">> -> {error, RespBody};
<<"204">> -> {ok, <<"">>};
<<"201">> -> {ok, created};
<<"201">> -> {ok, <<"created">>};
<<"200">> -> {ok, RespBody};
_ -> {error, RespBody}
end.

View File

@ -87,6 +87,6 @@ register_user(LUser, LServer) ->
%%--------------------------------------------------------------------
%% Internal functions.
%%--------------------------------------------------------------------
-spec build_bookmark(jid(), boolean()) -> bookmark_storage().
-spec build_bookmark(jid(), boolean()) -> bookmark_conference().
build_bookmark(Room, AutoJoin) ->
#bookmark_conference{jid = Room, autojoin = AutoJoin}.

View File

@ -195,7 +195,7 @@ find_omemo_nodes(#ps_publish{node = Node, items = Items}) ->
find_omemo_nodes(_) ->
[].
-spec find_omemo_nodes(binary(), ps_items()) -> [binary()].
-spec find_omemo_nodes(binary(), [ps_item()]) -> [binary()].
find_omemo_nodes(<<?DEVICELIST_NODE>> = Node, [Item]) ->
[Node | find_bundle_nodes(Item)];
find_omemo_nodes(<<?DEVICELIST_NODE>> = Node, []) ->

View File

@ -67,7 +67,7 @@
%% -------------------------------------------------------------------
%% gen_mod callbacks.
%% -------------------------------------------------------------------
-spec start(binary(), gen_mod:opts()) -> {ok, _} | {ok, _, _} | {error, _}.
-spec start(binary(), gen_mod:opts()) -> ok | {ok, pid()} | {error, term()}.
start(Host, Opts) ->
ejabberd_hooks:add(user_send_packet, Host, ?MODULE,
log_packet_send, 42),
@ -75,7 +75,7 @@ start(Host, Opts) ->
log_packet_receive, 42),
ejabberd_hooks:add(offline_message_hook, Host, ?MODULE,
log_packet_offline, 42),
case gen_mod:start_child(?MODULE, global, Opts) of
case gen_mod:start_child(?MODULE, <<"global">>, Opts) of
{ok, Ref} ->
{ok, Ref};
{error, {already_started, Ref}} ->
@ -92,10 +92,10 @@ stop(Host) ->
log_packet_receive, 42),
ejabberd_hooks:delete(offline_message_hook, Host, ?MODULE,
log_packet_offline, 42),
gen_mod:stop_child(?MODULE, global),
gen_mod:stop_child(gen_mod:get_module_proc(global, ?MODULE)),
ok.
-spec mod_opt_type(atom()) -> fun((term()) -> term()).
-spec mod_opt_type(atom()) -> econf:validator().
mod_opt_type(filename) ->
econf:either(auto, econf:file(write)).
@ -210,7 +210,7 @@ log_packet(Direction, #message{from = From, to = To, type = Type} = Msg) ->
-spec is_carbon(message()) -> {true, direction()} | false.
is_carbon(#message{meta = #{carbon_copy := true}} = Msg) ->
case xmpp:has_subtag(Msg, #carbons_sent{}) of
case xmpp:has_subtag(Msg, #carbons_sent{forwarded = #forwarded{}}) of
true ->
{true, outgoing};
false ->