From 35d05f292556d36228dbd795e48a17f67c0a47c8 Mon Sep 17 00:00:00 2001 From: Badlop Date: Fri, 12 Aug 2022 17:57:07 +0200 Subject: [PATCH] Fix specs and other errores detected by Dialyzer --- ejabberd_auth_http/src/ejabberd_auth_http.erl | 4 ++-- mod_default_rooms/src/mod_default_rooms.erl | 2 +- mod_deny_omemo/src/mod_deny_omemo.erl | 2 +- mod_message_log/src/mod_message_log.erl | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ejabberd_auth_http/src/ejabberd_auth_http.erl b/ejabberd_auth_http/src/ejabberd_auth_http.erl index 2d2eb8b..b3ab6f1 100644 --- a/ejabberd_auth_http/src/ejabberd_auth_http.erl +++ b/ejabberd_auth_http/src/ejabberd_auth_http.erl @@ -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. diff --git a/mod_default_rooms/src/mod_default_rooms.erl b/mod_default_rooms/src/mod_default_rooms.erl index 01ee187..0ba4fa7 100644 --- a/mod_default_rooms/src/mod_default_rooms.erl +++ b/mod_default_rooms/src/mod_default_rooms.erl @@ -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}. diff --git a/mod_deny_omemo/src/mod_deny_omemo.erl b/mod_deny_omemo/src/mod_deny_omemo.erl index 4ae741e..31aa037 100644 --- a/mod_deny_omemo/src/mod_deny_omemo.erl +++ b/mod_deny_omemo/src/mod_deny_omemo.erl @@ -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(<> = Node, [Item]) -> [Node | find_bundle_nodes(Item)]; find_omemo_nodes(<> = Node, []) -> diff --git a/mod_message_log/src/mod_message_log.erl b/mod_message_log/src/mod_message_log.erl index 4e13e2a..95cface 100644 --- a/mod_message_log/src/mod_message_log.erl +++ b/mod_message_log/src/mod_message_log.erl @@ -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 ->