diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl index b894a59e8..0b119a414 100644 --- a/src/ejabberd_c2s.erl +++ b/src/ejabberd_c2s.erl @@ -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) ->