25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

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.
This commit is contained in:
Holger Weiss 2015-03-25 02:02:08 +01:00
parent 1b1878409f
commit f40e6a0421
3 changed files with 7 additions and 82 deletions

View File

@ -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),
SentStateData = send_packet(NewState, FixedPacket),
ejabberd_hooks:run(user_receive_packet,
SentState#state.server,
[SentState#state.jid, From, To,
FinalPacket]),
SentState
end,
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)

View File

@ -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,

View File

@ -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,