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),
|
||||
{true, Attrs, StateData#state{pres_a = NewA}};
|
||||
'subscribe' ->
|
||||
SRes = is_privacy_allow(From, To, Packet, StateData#state.privacy_list),
|
||||
SRes = is_privacy_allow(StateData, From, To, Packet, in),
|
||||
{SRes, Attrs, StateData};
|
||||
'subscribed' ->
|
||||
SRes = is_privacy_allow(From, To, Packet, StateData#state.privacy_list),
|
||||
SRes = is_privacy_allow(StateData, From, To, Packet, in),
|
||||
{SRes, Attrs, StateData};
|
||||
'unsubscribe' ->
|
||||
SRes = is_privacy_allow(From, To, Packet, StateData#state.privacy_list),
|
||||
SRes = is_privacy_allow(StateData, From, To, Packet, in),
|
||||
{SRes, Attrs, StateData};
|
||||
'unsubscribed' ->
|
||||
SRes = is_privacy_allow(From, To, Packet, StateData#state.privacy_list),
|
||||
SRes = is_privacy_allow(StateData, From, To, Packet, in),
|
||||
{SRes, Attrs, StateData};
|
||||
_ ->
|
||||
case ejabberd_hooks:run_fold(
|
||||
@ -1852,18 +1852,19 @@ check_privacy_route(From, StateData, FromRoute, To, Packet) ->
|
||||
ejabberd_router:route(FromRoute, To, Packet)
|
||||
end.
|
||||
|
||||
privacy_check_packet(StateData, From, To, Packet, Dir) ->
|
||||
ejabberd_hooks:run_fold(
|
||||
privacy_check_packet, StateData#state.server,
|
||||
allow,
|
||||
[StateData#state.user,
|
||||
StateData#state.server,
|
||||
StateData#state.privacy_list,
|
||||
{From, To, Packet},
|
||||
Dir]).
|
||||
|
||||
%% Check if privacy rules allow this delivery
|
||||
is_privacy_allow(From, To, Packet, PrivacyList) ->
|
||||
User = exmpp_jid:prep_node(To),
|
||||
Server = exmpp_jid:prep_domain(To),
|
||||
allow == ejabberd_hooks:run_fold(
|
||||
privacy_check_packet, Server,
|
||||
allow,
|
||||
[User,
|
||||
Server,
|
||||
PrivacyList,
|
||||
{From, To, Packet},
|
||||
in]).
|
||||
is_privacy_allow(StateData, From, To, Packet, Dir) ->
|
||||
allow == privacy_check_packet(StateData, From, To, Packet, Dir).
|
||||
|
||||
%% Send presence when disconnecting
|
||||
presence_broadcast(StateData, From, JIDSet, Packet) ->
|
||||
|
Loading…
Reference in New Issue
Block a user