mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
Use ejabberd_c2s:privacy_check_packet/5 for all those hook folded runs in the c2s module
This commit is contained in:
parent
c47252aea1
commit
cb7d8c8ead
@ -1168,14 +1168,7 @@ handle_info({route, From, To, Packet}, StateName, StateData) ->
|
|||||||
SRes = is_privacy_allow(StateData, From, To, Packet, in),
|
SRes = is_privacy_allow(StateData, From, To, Packet, in),
|
||||||
{SRes, Attrs, StateData};
|
{SRes, Attrs, StateData};
|
||||||
_ ->
|
_ ->
|
||||||
case ejabberd_hooks:run_fold(
|
case privacy_check_packet(StateData, From, To, Packet, in) of
|
||||||
privacy_check_packet, StateData#state.server,
|
|
||||||
allow,
|
|
||||||
[StateData#state.user,
|
|
||||||
StateData#state.server,
|
|
||||||
StateData#state.privacy_list,
|
|
||||||
{From, To, Packet},
|
|
||||||
in]) of
|
|
||||||
allow ->
|
allow ->
|
||||||
LFrom = jlib:jid_tolower(From),
|
LFrom = jlib:jid_tolower(From),
|
||||||
LBFrom = jlib:jid_remove_resource(LFrom),
|
LBFrom = jlib:jid_remove_resource(LFrom),
|
||||||
@ -1266,14 +1259,7 @@ handle_info({route, From, To, Packet}, StateName, StateData) ->
|
|||||||
end,
|
end,
|
||||||
{false, Attrs, StateData};
|
{false, Attrs, StateData};
|
||||||
IQ when (is_record(IQ, iq)) or (IQ == reply) ->
|
IQ when (is_record(IQ, iq)) or (IQ == reply) ->
|
||||||
case ejabberd_hooks:run_fold(
|
case privacy_check_packet(StateData, From, To, Packet, in) of
|
||||||
privacy_check_packet, StateData#state.server,
|
|
||||||
allow,
|
|
||||||
[StateData#state.user,
|
|
||||||
StateData#state.server,
|
|
||||||
StateData#state.privacy_list,
|
|
||||||
{From, To, Packet},
|
|
||||||
in]) of
|
|
||||||
allow ->
|
allow ->
|
||||||
{true, Attrs, StateData};
|
{true, Attrs, StateData};
|
||||||
deny when is_record(IQ, iq) ->
|
deny when is_record(IQ, iq) ->
|
||||||
@ -1288,14 +1274,7 @@ handle_info({route, From, To, Packet}, StateName, StateData) ->
|
|||||||
{false, Attrs, StateData}
|
{false, Attrs, StateData}
|
||||||
end;
|
end;
|
||||||
"message" ->
|
"message" ->
|
||||||
case ejabberd_hooks:run_fold(
|
case privacy_check_packet(StateData, From, To, Packet, in) of
|
||||||
privacy_check_packet, StateData#state.server,
|
|
||||||
allow,
|
|
||||||
[StateData#state.user,
|
|
||||||
StateData#state.server,
|
|
||||||
StateData#state.privacy_list,
|
|
||||||
{From, To, Packet},
|
|
||||||
in]) of
|
|
||||||
allow ->
|
allow ->
|
||||||
case ejabberd_hooks:run_fold(
|
case ejabberd_hooks:run_fold(
|
||||||
feature_check_packet, StateData#state.server,
|
feature_check_packet, StateData#state.server,
|
||||||
@ -1604,14 +1583,7 @@ process_presence_probe(From, To, StateData) ->
|
|||||||
[jlib:timestamp_to_xml(Timestamp, utc, To, ""),
|
[jlib:timestamp_to_xml(Timestamp, utc, To, ""),
|
||||||
%% TODO: Delete the next line once XEP-0091 is Obsolete
|
%% TODO: Delete the next line once XEP-0091 is Obsolete
|
||||||
jlib:timestamp_to_xml(Timestamp)]),
|
jlib:timestamp_to_xml(Timestamp)]),
|
||||||
case ejabberd_hooks:run_fold(
|
case privacy_check_packet(StateData, To, From, Packet, out) of
|
||||||
privacy_check_packet, StateData#state.server,
|
|
||||||
allow,
|
|
||||||
[StateData#state.user,
|
|
||||||
StateData#state.server,
|
|
||||||
StateData#state.privacy_list,
|
|
||||||
{To, From, Packet},
|
|
||||||
out]) of
|
|
||||||
deny ->
|
deny ->
|
||||||
ok;
|
ok;
|
||||||
allow ->
|
allow ->
|
||||||
@ -1806,14 +1778,7 @@ presence_track(From, To, Packet, StateData) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
check_privacy_route(From, StateData, FromRoute, To, Packet) ->
|
check_privacy_route(From, StateData, FromRoute, To, Packet) ->
|
||||||
case ejabberd_hooks:run_fold(
|
case privacy_check_packet(StateData, From, To, Packet, out) of
|
||||||
privacy_check_packet, StateData#state.server,
|
|
||||||
allow,
|
|
||||||
[StateData#state.user,
|
|
||||||
StateData#state.server,
|
|
||||||
StateData#state.privacy_list,
|
|
||||||
{From, To, Packet},
|
|
||||||
out]) of
|
|
||||||
deny ->
|
deny ->
|
||||||
Lang = StateData#state.lang,
|
Lang = StateData#state.lang,
|
||||||
ErrText = "Routing of this stanza was denied by your active privacy list",
|
ErrText = "Routing of this stanza was denied by your active privacy list",
|
||||||
@ -1841,14 +1806,7 @@ is_privacy_allow(StateData, From, To, Packet, Dir) ->
|
|||||||
presence_broadcast(StateData, From, JIDSet, Packet) ->
|
presence_broadcast(StateData, From, JIDSet, Packet) ->
|
||||||
lists:foreach(fun(JID) ->
|
lists:foreach(fun(JID) ->
|
||||||
FJID = jlib:make_jid(JID),
|
FJID = jlib:make_jid(JID),
|
||||||
case ejabberd_hooks:run_fold(
|
case privacy_check_packet(StateData, From, FJID, Packet, out) of
|
||||||
privacy_check_packet, StateData#state.server,
|
|
||||||
allow,
|
|
||||||
[StateData#state.user,
|
|
||||||
StateData#state.server,
|
|
||||||
StateData#state.privacy_list,
|
|
||||||
{From, FJID, Packet},
|
|
||||||
out]) of
|
|
||||||
deny ->
|
deny ->
|
||||||
ok;
|
ok;
|
||||||
allow ->
|
allow ->
|
||||||
@ -1862,14 +1820,7 @@ presence_broadcast_to_trusted(StateData, From, T, A, Packet) ->
|
|||||||
case ?SETS:is_element(JID, T) of
|
case ?SETS:is_element(JID, T) of
|
||||||
true ->
|
true ->
|
||||||
FJID = jlib:make_jid(JID),
|
FJID = jlib:make_jid(JID),
|
||||||
case ejabberd_hooks:run_fold(
|
case privacy_check_packet(StateData, From, FJID, Packet, out) of
|
||||||
privacy_check_packet, StateData#state.server,
|
|
||||||
allow,
|
|
||||||
[StateData#state.user,
|
|
||||||
StateData#state.server,
|
|
||||||
StateData#state.privacy_list,
|
|
||||||
{From, FJID, Packet},
|
|
||||||
out]) of
|
|
||||||
deny ->
|
deny ->
|
||||||
ok;
|
ok;
|
||||||
allow ->
|
allow ->
|
||||||
@ -1900,14 +1851,7 @@ presence_broadcast_first(From, StateData, Packet) ->
|
|||||||
As = ?SETS:fold(
|
As = ?SETS:fold(
|
||||||
fun(JID, A) ->
|
fun(JID, A) ->
|
||||||
FJID = jlib:make_jid(JID),
|
FJID = jlib:make_jid(JID),
|
||||||
case ejabberd_hooks:run_fold(
|
case privacy_check_packet(StateData, From, FJID, Packet, out) of
|
||||||
privacy_check_packet, StateData#state.server,
|
|
||||||
allow,
|
|
||||||
[StateData#state.user,
|
|
||||||
StateData#state.server,
|
|
||||||
StateData#state.privacy_list,
|
|
||||||
{From, FJID, Packet},
|
|
||||||
out]) of
|
|
||||||
deny ->
|
deny ->
|
||||||
ok;
|
ok;
|
||||||
allow ->
|
allow ->
|
||||||
@ -1962,14 +1906,7 @@ roster_change(IJID, ISubscription, StateData) ->
|
|||||||
if
|
if
|
||||||
Cond1 ->
|
Cond1 ->
|
||||||
?DEBUG("C1: ~p~n", [LIJID]),
|
?DEBUG("C1: ~p~n", [LIJID]),
|
||||||
case ejabberd_hooks:run_fold(
|
case privacy_check_packet(StateData, From, To, P, out) of
|
||||||
privacy_check_packet, StateData#state.server,
|
|
||||||
allow,
|
|
||||||
[StateData#state.user,
|
|
||||||
StateData#state.server,
|
|
||||||
StateData#state.privacy_list,
|
|
||||||
{From, To, P},
|
|
||||||
out]) of
|
|
||||||
deny ->
|
deny ->
|
||||||
ok;
|
ok;
|
||||||
allow ->
|
allow ->
|
||||||
@ -1984,14 +1921,7 @@ roster_change(IJID, ISubscription, StateData) ->
|
|||||||
?DEBUG("C2: ~p~n", [LIJID]),
|
?DEBUG("C2: ~p~n", [LIJID]),
|
||||||
PU = {xmlelement, "presence",
|
PU = {xmlelement, "presence",
|
||||||
[{"type", "unavailable"}], []},
|
[{"type", "unavailable"}], []},
|
||||||
case ejabberd_hooks:run_fold(
|
case privacy_check_packet(StateData, From, To, PU, out) of
|
||||||
privacy_check_packet, StateData#state.server,
|
|
||||||
allow,
|
|
||||||
[StateData#state.user,
|
|
||||||
StateData#state.server,
|
|
||||||
StateData#state.privacy_list,
|
|
||||||
{From, To, PU},
|
|
||||||
out]) of
|
|
||||||
deny ->
|
deny ->
|
||||||
ok;
|
ok;
|
||||||
allow ->
|
allow ->
|
||||||
@ -2069,25 +1999,16 @@ process_privacy_iq(From, To,
|
|||||||
NewStateData.
|
NewStateData.
|
||||||
|
|
||||||
|
|
||||||
resend_offline_messages(#state{user = User,
|
resend_offline_messages(StateData) ->
|
||||||
server = Server,
|
case ejabberd_hooks:run_fold(
|
||||||
privacy_list = PrivList} = StateData) ->
|
resend_offline_messages_hook, StateData#state.server,
|
||||||
case ejabberd_hooks:run_fold(resend_offline_messages_hook,
|
[],
|
||||||
Server,
|
[StateData#state.user, StateData#state.server]) of
|
||||||
[],
|
|
||||||
[User, Server]) of
|
|
||||||
Rs when is_list(Rs) ->
|
Rs when is_list(Rs) ->
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun({route,
|
fun({route,
|
||||||
From, To, {xmlelement, Name, Attrs, Els} = Packet}) ->
|
From, To, {xmlelement, Name, Attrs, Els} = Packet}) ->
|
||||||
Pass = case ejabberd_hooks:run_fold(
|
Pass = case privacy_check_packet(StateData, From, To, Packet, in) of
|
||||||
privacy_check_packet, Server,
|
|
||||||
allow,
|
|
||||||
[User,
|
|
||||||
Server,
|
|
||||||
PrivList,
|
|
||||||
{From, To, Packet},
|
|
||||||
in]) of
|
|
||||||
allow ->
|
allow ->
|
||||||
true;
|
true;
|
||||||
deny ->
|
deny ->
|
||||||
|
Loading…
Reference in New Issue
Block a user