mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
* src/ejabberd_c2s.erl: Enforce privacy rules also for
subscription requests (EJAB-300) * src/ejabberd_sm.erl: Likewise SVN Revision: 1976
This commit is contained in:
parent
06eb54fef8
commit
787d225f1e
@ -1,3 +1,9 @@
|
||||
2009-03-07 Badlop <badlop@process-one.net>
|
||||
|
||||
* src/ejabberd_c2s.erl: Enforce privacy rules also for
|
||||
subscription requests (EJAB-300)
|
||||
* src/ejabberd_sm.erl: Likewise
|
||||
|
||||
2009-03-06 Evgeniy Khramtsov <ekhramtsov@process-one.net>
|
||||
|
||||
* src/ejabberd_hooks.erl: anonymous functions support.
|
||||
|
@ -1103,13 +1103,22 @@ handle_info({route, From, To, Packet}, StateName, StateData) ->
|
||||
Attrs1 = lists:keydelete("type", 1, Attrs),
|
||||
{true, [{"type", "unavailable"} | Attrs1], StateData};
|
||||
"subscribe" ->
|
||||
{true, Attrs, StateData};
|
||||
Reason = xml:get_path_s(Packet,[{elem,"status"},cdata]),
|
||||
SRes = check_privacy_subs(in, subscribe, From, To,
|
||||
Packet, Reason, StateData),
|
||||
{SRes, Attrs, StateData};
|
||||
"subscribed" ->
|
||||
{true, Attrs, StateData};
|
||||
SRes = check_privacy_subs(in, subscribed, From, To,
|
||||
Packet, "", StateData),
|
||||
{SRes, Attrs, StateData};
|
||||
"unsubscribe" ->
|
||||
{true, Attrs, StateData};
|
||||
SRes = check_privacy_subs(in, unsubscribe, From, To,
|
||||
Packet, "", StateData),
|
||||
{SRes, Attrs, StateData};
|
||||
"unsubscribed" ->
|
||||
{true, Attrs, StateData};
|
||||
SRes = check_privacy_subs(in, unsubscribed, From, To,
|
||||
Packet, "", StateData),
|
||||
{SRes, Attrs, StateData};
|
||||
_ ->
|
||||
case ejabberd_hooks:run_fold(
|
||||
privacy_check_packet, StateData#state.server,
|
||||
@ -1642,6 +1651,36 @@ check_privacy_route(From, StateData, FromRoute, To, Packet) ->
|
||||
ejabberd_router:route(FromRoute, To, Packet)
|
||||
end.
|
||||
|
||||
%% Check privacy rules for subscription requests and call the roster storage
|
||||
check_privacy_subs(Dir, Type, From, To, Packet, Reason, StateData) ->
|
||||
case is_privacy_allow(From, To, Dir, Packet, StateData) of
|
||||
true ->
|
||||
ejabberd_hooks:run_fold(
|
||||
roster_in_subscription,
|
||||
To#jid.lserver,
|
||||
false,
|
||||
[To#jid.user, To#jid.server, From, Type, Reason]),
|
||||
true;
|
||||
false ->
|
||||
false
|
||||
end.
|
||||
|
||||
%% Check if privacy rules allow this delivery, then push to roster
|
||||
is_privacy_allow(From, To, Dir, Packet, StateData) ->
|
||||
case 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]) of
|
||||
deny ->
|
||||
false;
|
||||
allow ->
|
||||
true
|
||||
end.
|
||||
|
||||
presence_broadcast(StateData, From, JIDSet, Packet) ->
|
||||
lists:foreach(fun(JID) ->
|
||||
FJID = jlib:make_jid(JID),
|
||||
|
@ -380,36 +380,13 @@ do_route(From, To, Packet) ->
|
||||
{Pass, _Subsc} =
|
||||
case xml:get_attr_s("type", Attrs) of
|
||||
"subscribe" ->
|
||||
Reason = xml:get_path_s(
|
||||
Packet,
|
||||
[{elem, "status"}, cdata]),
|
||||
{ejabberd_hooks:run_fold(
|
||||
roster_in_subscription,
|
||||
LServer,
|
||||
false,
|
||||
[User, Server, From, subscribe, Reason]),
|
||||
true};
|
||||
{true, true};
|
||||
"subscribed" ->
|
||||
{ejabberd_hooks:run_fold(
|
||||
roster_in_subscription,
|
||||
LServer,
|
||||
false,
|
||||
[User, Server, From, subscribed, ""]),
|
||||
true};
|
||||
{true, true};
|
||||
"unsubscribe" ->
|
||||
{ejabberd_hooks:run_fold(
|
||||
roster_in_subscription,
|
||||
LServer,
|
||||
false,
|
||||
[User, Server, From, unsubscribe, ""]),
|
||||
true};
|
||||
{true, true};
|
||||
"unsubscribed" ->
|
||||
{ejabberd_hooks:run_fold(
|
||||
roster_in_subscription,
|
||||
LServer,
|
||||
false,
|
||||
[User, Server, From, unsubscribed, ""]),
|
||||
true};
|
||||
{true, true};
|
||||
_ ->
|
||||
{true, false}
|
||||
end,
|
||||
|
Loading…
Reference in New Issue
Block a user