mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Use c2s state data as user and server in ejabberd_c2s:is_privacy_allow
is_privacy_allow is only used in ejabberd_c2s:handle_info/3 to determine for a few presence types whether the packet is allowed to be forwarded to the user's client. This only makes sense if To#jid.user and To#jid.server match StateData#state.user and StateData#state.server. Also, add the atom in as parameter to a new argument Dir of is_privacy_allow and extract from that function privacy_check_packet(StateData, From, To, Packet, Dir) which runs the privavcy check without converting allow/deny to true/false.
This commit is contained in:
parent
642b18edcb
commit
614f13714c
@ -1203,16 +1203,16 @@ handle_info({route, From, To, Packet}, StateName, StateData) ->
|
|||||||
StateData#state.pres_a),
|
StateData#state.pres_a),
|
||||||
{true, Attrs, StateData#state{pres_a = NewA}};
|
{true, Attrs, StateData#state{pres_a = NewA}};
|
||||||
'subscribe' ->
|
'subscribe' ->
|
||||||
SRes = is_privacy_allow(From, To, Packet, StateData#state.privacy_list),
|
SRes = is_privacy_allow(StateData, From, To, Packet, in),
|
||||||
{SRes, Attrs, StateData};
|
{SRes, Attrs, StateData};
|
||||||
'subscribed' ->
|
'subscribed' ->
|
||||||
SRes = is_privacy_allow(From, To, Packet, StateData#state.privacy_list),
|
SRes = is_privacy_allow(StateData, From, To, Packet, in),
|
||||||
{SRes, Attrs, StateData};
|
{SRes, Attrs, StateData};
|
||||||
'unsubscribe' ->
|
'unsubscribe' ->
|
||||||
SRes = is_privacy_allow(From, To, Packet, StateData#state.privacy_list),
|
SRes = is_privacy_allow(StateData, From, To, Packet, in),
|
||||||
{SRes, Attrs, StateData};
|
{SRes, Attrs, StateData};
|
||||||
'unsubscribed' ->
|
'unsubscribed' ->
|
||||||
SRes = is_privacy_allow(From, To, Packet, StateData#state.privacy_list),
|
SRes = is_privacy_allow(StateData, From, To, Packet, in),
|
||||||
{SRes, Attrs, StateData};
|
{SRes, Attrs, StateData};
|
||||||
_ ->
|
_ ->
|
||||||
case ejabberd_hooks:run_fold(
|
case ejabberd_hooks:run_fold(
|
||||||
@ -1852,18 +1852,19 @@ check_privacy_route(From, StateData, FromRoute, To, Packet) ->
|
|||||||
ejabberd_router:route(FromRoute, To, Packet)
|
ejabberd_router:route(FromRoute, To, Packet)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% Check if privacy rules allow this delivery
|
privacy_check_packet(StateData, From, To, Packet, Dir) ->
|
||||||
is_privacy_allow(From, To, Packet, PrivacyList) ->
|
ejabberd_hooks:run_fold(
|
||||||
User = exmpp_jid:prep_node(To),
|
privacy_check_packet, StateData#state.server,
|
||||||
Server = exmpp_jid:prep_domain(To),
|
|
||||||
allow == ejabberd_hooks:run_fold(
|
|
||||||
privacy_check_packet, Server,
|
|
||||||
allow,
|
allow,
|
||||||
[User,
|
[StateData#state.user,
|
||||||
Server,
|
StateData#state.server,
|
||||||
PrivacyList,
|
StateData#state.privacy_list,
|
||||||
{From, To, Packet},
|
{From, To, Packet},
|
||||||
in]).
|
Dir]).
|
||||||
|
|
||||||
|
%% Check if privacy rules allow this delivery
|
||||||
|
is_privacy_allow(StateData, From, To, Packet, Dir) ->
|
||||||
|
allow == privacy_check_packet(StateData, From, To, Packet, Dir).
|
||||||
|
|
||||||
%% Send presence when disconnecting
|
%% Send presence when disconnecting
|
||||||
presence_broadcast(StateData, From, JIDSet, Packet) ->
|
presence_broadcast(StateData, From, JIDSet, Packet) ->
|
||||||
|
Loading…
Reference in New Issue
Block a user