From f40e6a0421f382c52216a47b4ffaf19c95a3cc70 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Wed, 25 Mar 2015 02:02:08 +0100 Subject: [PATCH] Don't bother with filtering out PEP error messages Now that ejabberd_sm won't deliver error messages that were sent to bare JIDs anymore, PEP error messages should no longer arrive. --- src/ejabberd_c2s.erl | 21 +++++---------------- src/mod_pubsub.erl | 34 +--------------------------------- src/mod_pubsub_odbc.erl | 34 +--------------------------------- 3 files changed, 7 insertions(+), 82 deletions(-) diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl index 0e3f856ca..e739c6789 100644 --- a/src/ejabberd_c2s.erl +++ b/src/ejabberd_c2s.erl @@ -1700,23 +1700,12 @@ handle_info({route, From, To, jlib:replace_from_to_attrs(jlib:jid_to_string(From), jlib:jid_to_string(To), NewAttrs), FixedPacket = #xmlel{name = Name, attrs = Attrs2, children = Els}, - FinalState = - case ejabberd_hooks:run_fold(c2s_filter_packet_in, - NewState#state.server, FixedPacket, - [NewState#state.jid, From, To]) - of - drop -> - NewState; - FinalPacket = #xmlel{} -> - SentState = send_packet(NewState, FinalPacket), - ejabberd_hooks:run(user_receive_packet, - SentState#state.server, - [SentState#state.jid, From, To, - FinalPacket]), - SentState - end, + SentStateData = send_packet(NewState, FixedPacket), + ejabberd_hooks:run(user_receive_packet, + SentStateData#state.server, + [SentStateData#state.jid, From, To, FixedPacket]), ejabberd_hooks:run(c2s_loop_debug, [{route, From, To, Packet}]), - fsm_next_state(StateName, FinalState); + fsm_next_state(StateName, SentStateData); true -> ejabberd_hooks:run(c2s_loop_debug, [{route, From, To, Packet}]), fsm_next_state(StateName, NewState) diff --git a/src/mod_pubsub.erl b/src/mod_pubsub.erl index 08e351462..579c47757 100644 --- a/src/mod_pubsub.erl +++ b/src/mod_pubsub.erl @@ -74,8 +74,7 @@ on_user_offline/3, remove_user/2, disco_local_identity/5, disco_local_features/5, disco_local_items/5, disco_sm_identity/5, - disco_sm_features/5, disco_sm_items/5, - drop_pep_error/4]). + disco_sm_features/5, disco_sm_items/5]). %% exported iq handlers -export([iq_sm/3]). @@ -345,8 +344,6 @@ init([ServerHost, Opts]) -> ?MODULE, disco_sm_features, 75), ejabberd_hooks:add(disco_sm_items, ServerHost, ?MODULE, disco_sm_items, 75), - ejabberd_hooks:add(c2s_filter_packet_in, ServerHost, ?MODULE, - drop_pep_error, 75), gen_iq_handler:add_iq_handler(ejabberd_sm, ServerHost, ?NS_PUBSUB, ?MODULE, iq_sm, IQDisc), gen_iq_handler:add_iq_handler(ejabberd_sm, ServerHost, @@ -1331,33 +1328,6 @@ unsubscribe_user(Entity, Owner) -> plugins(Host)) end). -%% ------- -%% packet receive hook handling function -%% - -drop_pep_error(#xmlel{name = <<"message">>, attrs = Attrs} = Packet, _JID, From, - #jid{lresource = <<"">>} = To) -> - case xml:get_attr_s(<<"type">>, Attrs) of - <<"error">> -> - case xml:get_subtag(Packet, <<"event">>) of - #xmlel{attrs = EventAttrs} -> - case xml:get_attr_s(<<"xmlns">>, EventAttrs) of - ?NS_PUBSUB_EVENT -> - ?DEBUG("Dropping PEP error message from ~s to ~s", - [jlib:jid_to_string(From), - jlib:jid_to_string(To)]), - drop; - _ -> - Packet - end; - false -> - Packet - end; - _ -> - Packet - end; -drop_pep_error(Acc, _JID, _From, _To) -> Acc. - %% ------- %% user remove hook handling function %% @@ -1498,8 +1468,6 @@ terminate(_Reason, ?MODULE, disco_sm_features, 75), ejabberd_hooks:delete(disco_sm_items, ServerHost, ?MODULE, disco_sm_items, 75), - ejabberd_hooks:delete(c2s_filter_packet_in, ServerHost, - ?MODULE, drop_pep_error, 75), gen_iq_handler:remove_iq_handler(ejabberd_sm, ServerHost, ?NS_PUBSUB), gen_iq_handler:remove_iq_handler(ejabberd_sm, diff --git a/src/mod_pubsub_odbc.erl b/src/mod_pubsub_odbc.erl index 4b9787821..8b32b83e2 100644 --- a/src/mod_pubsub_odbc.erl +++ b/src/mod_pubsub_odbc.erl @@ -74,8 +74,7 @@ on_user_offline/3, remove_user/2, disco_local_identity/5, disco_local_features/5, disco_local_items/5, disco_sm_identity/5, - disco_sm_features/5, disco_sm_items/5, - drop_pep_error/4]). + disco_sm_features/5, disco_sm_items/5]). %% exported iq handlers -export([iq_sm/3]). @@ -345,8 +344,6 @@ init([ServerHost, Opts]) -> ?MODULE, disco_sm_features, 75), ejabberd_hooks:add(disco_sm_items, ServerHost, ?MODULE, disco_sm_items, 75), - ejabberd_hooks:add(c2s_filter_packet_in, ServerHost, ?MODULE, - drop_pep_error, 75), gen_iq_handler:add_iq_handler(ejabberd_sm, ServerHost, ?NS_PUBSUB, ?MODULE, iq_sm, IQDisc), gen_iq_handler:add_iq_handler(ejabberd_sm, ServerHost, @@ -941,33 +938,6 @@ unsubscribe_user(Entity, Owner) -> plugins(Host)) end). -%% ------- -%% packet receive hook handling function -%% - -drop_pep_error(#xmlel{name = <<"message">>, attrs = Attrs} = Packet, _JID, From, - #jid{lresource = <<"">>} = To) -> - case xml:get_attr_s(<<"type">>, Attrs) of - <<"error">> -> - case xml:get_subtag(Packet, <<"event">>) of - #xmlel{attrs = EventAttrs} -> - case xml:get_attr_s(<<"xmlns">>, EventAttrs) of - ?NS_PUBSUB_EVENT -> - ?DEBUG("Dropping PEP error message from ~s to ~s", - [jlib:jid_to_string(From), - jlib:jid_to_string(To)]), - drop; - _ -> - Packet - end; - false -> - Packet - end; - _ -> - Packet - end; -drop_pep_error(Acc, _JID, _From, _To) -> Acc. - %% ------- %% user remove hook handling function %% @@ -1108,8 +1078,6 @@ terminate(_Reason, ?MODULE, disco_sm_features, 75), ejabberd_hooks:delete(disco_sm_items, ServerHost, ?MODULE, disco_sm_items, 75), - ejabberd_hooks:delete(c2s_filter_packet_in, ServerHost, - ?MODULE, drop_pep_error, 75), gen_iq_handler:remove_iq_handler(ejabberd_sm, ServerHost, ?NS_PUBSUB), gen_iq_handler:remove_iq_handler(ejabberd_sm,