diff --git a/src/jlib.erl b/src/jlib.erl index f25305c968..fadfc302be 100644 --- a/src/jlib.erl +++ b/src/jlib.erl @@ -28,8 +28,7 @@ -xep([{xep, 59}, {version, "1.0"}]). -xep([{xep, 68}, {version, "1.2"}]). -xep([{xep, 86}, {version, "1.0"}]). --export([make_result_iq_reply/1, - make_error_reply/2, +-export([make_error_reply/2, make_error_reply/3, make_invitation/3, make_config_change_message/1, @@ -86,37 +85,6 @@ iq/0 ]). --spec make_result_iq_reply(exml:element()) -> exml:element(); - (iq()) -> iq(). -make_result_iq_reply(XE = #xmlel{attrs = Attrs}) -> - NewAttrs = make_result_iq_reply_attrs(Attrs), - XE#xmlel{attrs = NewAttrs}; -make_result_iq_reply(IQ = #iq{}) -> - IQ#iq{ type = result }. - - --spec make_result_iq_reply_attrs([binary_pair()]) -> [binary_pair(), ...]. -make_result_iq_reply_attrs(Attrs) -> - To = xml:get_attr(<<"to">>, Attrs), - From = xml:get_attr(<<"from">>, Attrs), - Attrs1 = lists:keydelete(<<"to">>, 1, Attrs), - Attrs2 = lists:keydelete(<<"from">>, 1, Attrs1), - Attrs3 = case To of - {value, ToVal} -> - [{<<"from">>, ToVal} | Attrs2]; - _ -> - Attrs2 - end, - Attrs4 = case From of - {value, FromVal} -> - [{<<"to">>, FromVal} | Attrs3]; - _ -> - Attrs3 - end, - Attrs5 = lists:keydelete(<<"type">>, 1, Attrs4), - [{<<"type">>, <<"result">>} | Attrs5]. - - -spec make_error_reply(exml:element() | mongoose_acc:t(), xmlcdata() | exml:element()) -> exml:element() | {mongoose_acc:t(), exml:element() | {error, {already_an_error, _, _}}}. diff --git a/src/mongoose_acc.erl b/src/mongoose_acc.erl index c1c6a43cf0..9ba2b85294 100644 --- a/src/mongoose_acc.erl +++ b/src/mongoose_acc.erl @@ -57,6 +57,7 @@ -export([strip/1, strip/2]). -ignore_xref([delete/2, ref/1]). +-ignore_xref([strip/1]). % TODO: Check %% Note about 'undefined' to_jid and from_jid: these are the special cases when JID may be %% truly unknown: before a client is authorized. diff --git a/src/mongoose_hooks.erl b/src/mongoose_hooks.erl index 1a83f2acb1..3e0d4ba2bc 100644 --- a/src/mongoose_hooks.erl +++ b/src/mongoose_hooks.erl @@ -31,25 +31,16 @@ rest_user_send_packet/4, session_cleanup/5, set_vcard/3, - unacknowledged_message/2, - filter_unacknowledged_messages/3, unregister_subhost/1, user_available_hook/2, user_ping_response/5, - user_receive_packet/6, - user_sent_keep_alive/2, user_send_packet/4, vcard_set/4, xmpp_send_element/3, xmpp_stanza_dropped/4]). -export([c2s_broadcast_recipients/4, - c2s_filter_packet/4, - c2s_preprocessing_hook/3, - c2s_presence_in/4, c2s_stream_features/2, - c2s_unauthenticated_iq/4, - c2s_update_presence/2, check_bl_c2s/1, forbidden_session_hook/3, session_opening_allowed_for_user/2]). @@ -153,8 +144,6 @@ -export([mod_global_distrib_known_recipient/4, mod_global_distrib_unknown_recipient/2]). --export([c2s_remote_hook/5]). - -export([remove_domain/2, node_cleanup/1]). @@ -172,17 +161,6 @@ Packet :: exml:element()}. -export_type([filter_packet_acc/0]). --spec c2s_remote_hook(HostType, Tag, Args, HandlerState, C2SState) -> Result when - HostType :: binary(), - Tag :: atom(), - Args :: term(), - HandlerState :: term(), - C2SState :: ejabberd_c2s:state(), - Result :: term(). % ok | empty_state | HandlerState -c2s_remote_hook(HostType, Tag, Args, HandlerState, C2SState) -> - run_hook_for_host_type(c2s_remote_hook, HostType, HandlerState, - [Tag, Args, C2SState]). - -spec adhoc_local_commands(HostType, From, To, AdhocRequest) -> Result when HostType :: mongooseim:host_type(), From :: jid:jid(), @@ -411,25 +389,6 @@ set_vcard(HostType, UserJID, VCard) -> run_hook_for_host_type(set_vcard, HostType, {error, no_handler_defined}, [HostType, UserJID, VCard]). --spec unacknowledged_message(Acc, JID) -> Result when - Acc :: mongoose_acc:t(), - JID :: jid:jid(), - Result :: mongoose_acc:t(). -unacknowledged_message(Acc, JID) -> - HostType = mongoose_acc:host_type(Acc), - Params = #{jid => JID}, - Args = [JID], - ParamsWithLegacyArgs = ejabberd_hooks:add_args(Params, Args), - run_hook_for_host_type(unacknowledged_message, HostType, Acc, ParamsWithLegacyArgs). - --spec filter_unacknowledged_messages(HostType, Jid, Buffer) -> Result when - HostType :: mongooseim:host_type(), - Jid :: jid:jid(), - Buffer :: [mongoose_acc:t()], - Result :: [mongoose_acc:t()]. -filter_unacknowledged_messages(HostType, Jid, Buffer) -> - run_fold(filter_unacknowledged_messages, HostType, Buffer, #{jid => Jid}). - %%% @doc The `unregister_subhost' hook is called when a component %%% is unregistered from ejabberd_router or a subdomain is removed from mongoose_subdomain_core. -spec unregister_subhost(LDomain) -> Result when @@ -463,24 +422,6 @@ user_ping_response(HostType, Acc, JID, Response, TDelta) -> ParamsWithLegacyArgs = ejabberd_hooks:add_args(Params, Args), run_hook_for_host_type(user_ping_response, HostType, Acc, ParamsWithLegacyArgs). --spec user_receive_packet(HostType, Acc, JID, From, To, El) -> Result when - HostType :: binary(), - Acc :: mongoose_acc:t(), - JID :: jid:jid(), - From :: jid:jid(), - To :: jid:jid(), - El :: exml:element(), - Result :: mongoose_acc:t(). -user_receive_packet(HostType, Acc, JID, From, To, El) -> - run_hook_for_host_type(user_receive_packet, HostType, Acc, [JID, From, To, El]). - --spec user_sent_keep_alive(HostType, JID) -> Result when - HostType :: binary(), - JID :: jid:jid(), - Result :: any(). -user_sent_keep_alive(HostType, JID) -> - run_hook_for_host_type(user_sent_keep_alive, HostType, ok, [JID]). - %%% @doc A hook called when a user sends an XMPP stanza. %%% The hook's handler is expected to accept four parameters: %%% `Acc', `From', `To' and `Packet' @@ -542,35 +483,6 @@ c2s_broadcast_recipients(State, Type, From, Packet) -> run_hook_for_host_type(c2s_broadcast_recipients, HostType, [], [State, Type, From, Packet]). --spec c2s_filter_packet(State, Feature, To, Packet) -> Result when - State :: ejabberd_c2s:state(), - Feature :: {atom(), binary()}, - To :: jid:jid(), - Packet :: exml:element(), - Result :: boolean(). -c2s_filter_packet(State, Feature, To, Packet) -> - HostType = ejabberd_c2s_state:host_type(State), - run_hook_for_host_type(c2s_filter_packet, HostType, true, - [State, Feature, To, Packet]). - --spec c2s_preprocessing_hook(HostType, Acc, State) -> Result when - HostType :: mongooseim:host_type(), - Acc :: mongoose_acc:t(), - State :: mongoose_c2s:c2s_data(), - Result :: mongoose_acc:t(). -c2s_preprocessing_hook(HostType, Acc, State) -> - run_hook_for_host_type(c2s_preprocessing_hook, HostType, Acc, [State]). - --spec c2s_presence_in(State, From, To, Packet) -> Result when - State :: ejabberd_c2s:state(), - From :: jid:jid(), - To :: jid:jid(), - Packet :: exml:element(), - Result :: ejabberd_c2s:state(). -c2s_presence_in(State, From, To, Packet) -> - HostType = ejabberd_c2s_state:host_type(State), - run_hook_for_host_type(c2s_presence_in, HostType, State, [From, To, Packet]). - -spec c2s_stream_features(HostType, LServer) -> Result when HostType :: mongooseim:host_type(), LServer :: jid:lserver(), @@ -578,22 +490,6 @@ c2s_presence_in(State, From, To, Packet) -> c2s_stream_features(HostType, LServer) -> run_hook_for_host_type(c2s_stream_features, HostType, [], [HostType, LServer]). --spec c2s_unauthenticated_iq(HostType, Server, IQ, IP) -> Result when - HostType :: mongooseim:host_type(), - Server :: jid:server(), - IQ :: jlib:iq(), - IP :: {inet:ip_address(), inet:port_number()} | undefined, - Result :: exml:element() | empty. -c2s_unauthenticated_iq(HostType, Server, IQ, IP) -> - run_hook_for_host_type(c2s_unauthenticated_iq, HostType, empty, [HostType, Server, IQ, IP]). - --spec c2s_update_presence(HostType, Acc) -> Result when - HostType :: mongooseim:host_type(), - Acc :: mongoose_acc:t(), - Result :: mongoose_acc:t(). -c2s_update_presence(HostType, Acc) -> - run_hook_for_host_type(c2s_update_presence, HostType, Acc, []). - -spec check_bl_c2s(IP) -> Result when IP :: inet:ip_address(), Result :: boolean(). diff --git a/src/mongoose_iq.erl b/src/mongoose_iq.erl index ccad77e3eb..69bfae5e21 100644 --- a/src/mongoose_iq.erl +++ b/src/mongoose_iq.erl @@ -23,6 +23,7 @@ -export([info/1, xmlns/1, command/1]). -ignore_xref([command/1, empty_result_iq/1, iq_to_sub_el/1, update_acc_info/1]). +-ignore_xref([xmlns/1]). -include("jlib.hrl").