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

Merge pull request #307 from weiss/remove-invisible-presence

Remove invisible presence fields from c2s #state
This commit is contained in:
Evgeny Khramtsov 2014-09-25 17:20:45 +04:00
commit ef89497d3f

View File

@ -99,10 +99,8 @@
pres_t = ?SETS:new(), pres_t = ?SETS:new(),
pres_f = ?SETS:new(), pres_f = ?SETS:new(),
pres_a = ?SETS:new(), pres_a = ?SETS:new(),
pres_i = ?SETS:new(),
pres_last, pres_pri, pres_last, pres_pri,
pres_timestamp, pres_timestamp,
pres_invis = false,
privacy_list = #userlist{}, privacy_list = #userlist{},
conn = unknown, conn = unknown,
auth_module = unknown, auth_module = unknown,
@ -1758,11 +1756,10 @@ handle_info(Info, StateName, StateData) ->
%% Purpose: Prepare the state to be printed on error log %% Purpose: Prepare the state to be printed on error log
%% Returns: State to print %% Returns: State to print
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
print_state(State = #state{pres_t = T, pres_f = F, pres_a = A, pres_i = I}) -> print_state(State = #state{pres_t = T, pres_f = F, pres_a = A}) ->
State#state{pres_t = {pres_t, ?SETS:size(T)}, State#state{pres_t = {pres_t, ?SETS:size(T)},
pres_f = {pres_f, ?SETS:size(F)}, pres_f = {pres_f, ?SETS:size(F)},
pres_a = {pres_a, ?SETS:size(A)}, pres_a = {pres_a, ?SETS:size(A)}
pres_i = {pres_i, ?SETS:size(I)}
}. }.
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
@ -1798,8 +1795,6 @@ terminate(_Reason, StateName, StateData) ->
<<"Replaced by new connection">>), <<"Replaced by new connection">>),
presence_broadcast(StateData, From, presence_broadcast(StateData, From,
StateData#state.pres_a, Packet), StateData#state.pres_a, Packet),
presence_broadcast(StateData, From,
StateData#state.pres_i, Packet),
handle_unacked_stanzas(StateData); handle_unacked_stanzas(StateData);
_ -> _ ->
?INFO_MSG("(~w) Close session for ~s", ?INFO_MSG("(~w) Close session for ~s",
@ -1807,10 +1802,7 @@ terminate(_Reason, StateName, StateData) ->
jlib:jid_to_string(StateData#state.jid)]), jlib:jid_to_string(StateData#state.jid)]),
EmptySet = (?SETS):new(), EmptySet = (?SETS):new(),
case StateData of case StateData of
#state{pres_last = undefined, #state{pres_last = undefined, pres_a = EmptySet} ->
pres_a = EmptySet,
pres_i = EmptySet,
pres_invis = false} ->
ejabberd_sm:close_session(StateData#state.sid, ejabberd_sm:close_session(StateData#state.sid,
StateData#state.user, StateData#state.user,
StateData#state.server, StateData#state.server,
@ -1826,9 +1818,7 @@ terminate(_Reason, StateName, StateData) ->
StateData#state.resource, StateData#state.resource,
<<"">>), <<"">>),
presence_broadcast(StateData, From, presence_broadcast(StateData, From,
StateData#state.pres_a, Packet), StateData#state.pres_a, Packet)
presence_broadcast(StateData, From,
StateData#state.pres_i, Packet)
end, end,
handle_unacked_stanzas(StateData) handle_unacked_stanzas(StateData)
end, end,
@ -2009,21 +1999,12 @@ process_presence_probe(From, To, StateData) ->
undefined -> undefined ->
ok; ok;
_ -> _ ->
Cond1 = (not StateData#state.pres_invis) Cond = ?SETS:is_element(LFrom, StateData#state.pres_f)
andalso (?SETS:is_element(LFrom, StateData#state.pres_f)
orelse orelse
((LFrom /= LBFrom) andalso ((LFrom /= LBFrom) andalso
?SETS:is_element(LBFrom, StateData#state.pres_f))) ?SETS:is_element(LBFrom, StateData#state.pres_f)),
andalso (not
(?SETS:is_element(LFrom, StateData#state.pres_i)
orelse
((LFrom /= LBFrom) andalso
?SETS:is_element(LBFrom, StateData#state.pres_i)))),
Cond2 = StateData#state.pres_invis
andalso ?SETS:is_element(LFrom, StateData#state.pres_f)
andalso ?SETS:is_element(LFrom, StateData#state.pres_a),
if if
Cond1 -> Cond ->
Timestamp = StateData#state.pres_timestamp, Timestamp = StateData#state.pres_timestamp,
Packet = xml:append_subtags( Packet = xml:append_subtags(
StateData#state.pres_last, StateData#state.pres_last,
@ -2045,11 +2026,6 @@ process_presence_probe(From, To, StateData) ->
ok ok
end end
end; end;
Cond2 ->
ejabberd_router:route(To, From,
#xmlel{name = <<"presence">>,
attrs = [],
children = []});
true -> true ->
ok ok
end end
@ -2976,11 +2952,9 @@ inherit_session_state(#state{user = U, server = S} = StateData, ResumeID) ->
pres_t = OldStateData#state.pres_t, pres_t = OldStateData#state.pres_t,
pres_f = OldStateData#state.pres_f, pres_f = OldStateData#state.pres_f,
pres_a = OldStateData#state.pres_a, pres_a = OldStateData#state.pres_a,
pres_i = OldStateData#state.pres_i,
pres_last = OldStateData#state.pres_last, pres_last = OldStateData#state.pres_last,
pres_pri = OldStateData#state.pres_pri, pres_pri = OldStateData#state.pres_pri,
pres_timestamp = OldStateData#state.pres_timestamp, pres_timestamp = OldStateData#state.pres_timestamp,
pres_invis = OldStateData#state.pres_invis,
privacy_list = OldStateData#state.privacy_list, privacy_list = OldStateData#state.privacy_list,
aux_fields = OldStateData#state.aux_fields, aux_fields = OldStateData#state.aux_fields,
csi_state = OldStateData#state.csi_state, csi_state = OldStateData#state.csi_state,