From bef66dba24dd4f03873140fe08950f47d1c1383a Mon Sep 17 00:00:00 2001 From: Alexey Shchepin Date: Tue, 30 Oct 2012 13:29:15 +0200 Subject: [PATCH] Don't try to send privacy pushes in OOR mode --- src/ejabberd_c2s.erl | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl index 221dc1744..8c646f8ab 100644 --- a/src/ejabberd_c2s.erl +++ b/src/ejabberd_c2s.erl @@ -1505,13 +1505,17 @@ handle_info({route, _From, _To, {broadcast, Data}}, attrs = [{<<"name">>, PrivListName}], children = []}]}]}, + PrivFrom = jlib:jid_remove_resource(StateData#state.jid), + PrivTo = StateData#state.jid, PrivPushEl = jlib:replace_from_to( - jlib:jid_remove_resource(StateData#state.jid), - StateData#state.jid, + PrivFrom, + PrivTo, jlib:iq_to_xml(PrivPushIQ)), send_element(StateData, PrivPushEl), + StateData2 = send_or_enqueue_packet( + StateData, PrivFrom, PrivTo, PrivPushEl), fsm_next_state(StateName, - StateData#state{privacy_list = NewPL}) + StateData2#state{privacy_list = NewPL}) end; {blocking, What} -> route_blocking(What, StateData), @@ -1788,18 +1792,7 @@ handle_info({route, From, To, jlib:jid_to_string(To), NewAttrs), FixedPacket = #xmlel{name = Name, attrs = Attrs2, children = Els}, - NewState2 = if NewState#state.reception and - not - (NewState#state.standby and - (Name /= "message")) -> - send_element(NewState, FixedPacket), - ack(NewState, From, To, FixedPacket); - true -> - NewState1 = - send_out_of_reception_message(NewState, From, - To, Packet), - enqueue(NewState1, From, To, FixedPacket) - end, + NewState2 = send_or_enqueue_packet(NewState, From, To, FixedPacket), ejabberd_hooks:run(user_receive_packet, StateData#state.server, [StateData#state.debug, StateData#state.jid, From, @@ -2134,6 +2127,19 @@ send_trailer(StateData) send_trailer(StateData) -> send_text(StateData, ?STREAM_TRAILER). +send_or_enqueue_packet(State, From, To, Packet) -> + #xmlel{name = Name} = Packet, + if State#state.reception and + not (State#state.standby and + (Name /= "message")) -> + send_element(State, Packet), + ack(State, From, To, Packet); + true -> + NewState = send_out_of_reception_message(State, From, To, Packet), + enqueue(NewState, From, To, Packet) + end. + + new_id() -> randoms:get_string(). is_auth_packet(El) ->