mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Merge 1998 from trunk.
* src/ejabberd_sm.erl: Partially retract SVN r1976 EJAB-300 (EJAB-890). Check default privacy list when account, not a specific session, receives a presence subscription stanza (EJAB-300). * src/ejabberd_c2s.erl: Likewise SVN Revision: 1999
This commit is contained in:
parent
3e756f5d1c
commit
61691ac47d
@ -1,3 +1,11 @@
|
||||
2009-03-24 Badlop <badlop@process-one.net>
|
||||
|
||||
* src/ejabberd_sm.erl: Partially retract SVN r1976
|
||||
EJAB-300 (EJAB-890). Check default privacy list when account, not
|
||||
a specific session, receives a presence subscription
|
||||
stanza (EJAB-300).
|
||||
* src/ejabberd_c2s.erl: Likewise
|
||||
|
||||
2009-03-20 Christophe Romain <christophe.romain@process-one.net>
|
||||
|
||||
* src/mod_pubsub/mod_pubsub.erl: implement roster acces model (thanks
|
||||
|
@ -1039,21 +1039,16 @@ handle_info({route, From, To, Packet}, StateName, StateData) ->
|
||||
'unavailable'),
|
||||
{true, Attrs1, StateData};
|
||||
'subscribe' ->
|
||||
Reason = exmpp_presence:get_status(Packet),
|
||||
SRes = check_privacy_subs(in, subscribe, From, To,
|
||||
Packet, Reason, StateData),
|
||||
SRes = is_privacy_allow(From, To, Packet, StateData#state.privacy_list),
|
||||
{SRes, Attrs, StateData};
|
||||
'subscribed' ->
|
||||
SRes = check_privacy_subs(in, subscribed, From, To,
|
||||
Packet, <<>>, StateData),
|
||||
SRes = is_privacy_allow(From, To, Packet, StateData#state.privacy_list),
|
||||
{SRes, Attrs, StateData};
|
||||
'unsubscribe' ->
|
||||
SRes = check_privacy_subs(in, unsubscribe, From, To,
|
||||
Packet, <<>>, StateData),
|
||||
SRes = is_privacy_allow(From, To, Packet, StateData#state.privacy_list),
|
||||
{SRes, Attrs, StateData};
|
||||
'unsubscribed' ->
|
||||
SRes = check_privacy_subs(in, unsubscribed, From, To,
|
||||
Packet, <<>>, StateData),
|
||||
SRes = is_privacy_allow(From, To, Packet, StateData#state.privacy_list),
|
||||
{SRes, Attrs, StateData};
|
||||
_ ->
|
||||
case ejabberd_hooks:run_fold(
|
||||
@ -1580,35 +1575,18 @@ 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,
|
||||
exmpp_jid:ldomain(To),
|
||||
false,
|
||||
[exmpp_jid:lnode(To), exmpp_jid:ldomain(To), 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,
|
||||
%% Check if privacy rules allow this delivery
|
||||
is_privacy_allow(From, To, Packet, PrivacyList) ->
|
||||
User = exmpp_jid:lnode(To),
|
||||
Server = exmpp_jid:ldomain(To),
|
||||
allow == ejabberd_hooks:run_fold(
|
||||
privacy_check_packet, Server,
|
||||
allow,
|
||||
[StateData#state.user,
|
||||
StateData#state.server,
|
||||
StateData#state.privacy_list,
|
||||
[User,
|
||||
Server,
|
||||
PrivacyList,
|
||||
{From, To, Packet},
|
||||
Dir]) of
|
||||
deny ->
|
||||
false;
|
||||
allow ->
|
||||
true
|
||||
end.
|
||||
in]).
|
||||
|
||||
presence_broadcast(StateData, From, JIDSet, Packet) ->
|
||||
lists:foreach(fun({U, S, R}) ->
|
||||
|
@ -62,6 +62,7 @@
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("ejabberd_commands.hrl").
|
||||
-include("mod_privacy.hrl").
|
||||
|
||||
-record(session, {sid, usr, us, priority, info}).
|
||||
-record(state, {}).
|
||||
@ -422,13 +423,38 @@ do_route(From, To, Packet) ->
|
||||
{Pass, _Subsc} =
|
||||
case exmpp_presence:get_type(Packet) of
|
||||
'subscribe' ->
|
||||
{true, true};
|
||||
Reason = exmpp_presence:get_status(Packet),
|
||||
{is_privacy_allow(From, To, Packet) andalso
|
||||
ejabberd_hooks:run_fold(
|
||||
roster_in_subscription,
|
||||
exmpp_jid:ldomain(To),
|
||||
false,
|
||||
[exmpp_jid:lnode(To), exmpp_jid:ldomain(To), From, subscribe, Reason]),
|
||||
true};
|
||||
'subscribed' ->
|
||||
{true, true};
|
||||
{is_privacy_allow(From, To, Packet) andalso
|
||||
ejabberd_hooks:run_fold(
|
||||
roster_in_subscription,
|
||||
exmpp_jid:ldomain(To),
|
||||
false,
|
||||
[exmpp_jid:lnode(To), exmpp_jid:ldomain(To), From, subscribed, <<>>]),
|
||||
true};
|
||||
'unsubscribe' ->
|
||||
{true, true};
|
||||
{is_privacy_allow(From, To, Packet) andalso
|
||||
ejabberd_hooks:run_fold(
|
||||
roster_in_subscription,
|
||||
exmpp_jid:ldomain(To),
|
||||
false,
|
||||
[exmpp_jid:lnode(To), exmpp_jid:ldomain(To), From, unsubscribe, <<>>]),
|
||||
true};
|
||||
'unsubscribed' ->
|
||||
{true, true};
|
||||
{is_privacy_allow(From, To, Packet) andalso
|
||||
ejabberd_hooks:run_fold(
|
||||
roster_in_subscription,
|
||||
exmpp_jid:ldomain(To),
|
||||
false,
|
||||
[exmpp_jid:lnode(To), exmpp_jid:ldomain(To), From, unsubscribed, <<>>]),
|
||||
true};
|
||||
_ ->
|
||||
{true, false}
|
||||
end,
|
||||
@ -490,6 +516,31 @@ do_route(From, To, Packet) ->
|
||||
end
|
||||
end.
|
||||
|
||||
%% The default list applies to the user as a whole,
|
||||
%% and is processed if there is no active list set
|
||||
%% for the target session/resource to which a stanza is addressed,
|
||||
%% or if there are no current sessions for the user.
|
||||
is_privacy_allow(From, To, Packet) ->
|
||||
User = exmpp_jid:lnode(To),
|
||||
Server = exmpp_jid:ldomain(To),
|
||||
PrivacyList = ejabberd_hooks:run_fold(privacy_get_user_list, Server,
|
||||
#userlist{}, [User, Server]),
|
||||
is_privacy_allow(From, To, Packet, PrivacyList).
|
||||
|
||||
%% Check if privacy rules allow this delivery
|
||||
%% Function copied from ejabberd_c2s.erl
|
||||
is_privacy_allow(From, To, Packet, PrivacyList) ->
|
||||
User = exmpp_jid:lnode(To),
|
||||
Server = exmpp_jid:ldomain(To),
|
||||
allow == ejabberd_hooks:run_fold(
|
||||
privacy_check_packet, Server,
|
||||
allow,
|
||||
[User,
|
||||
Server,
|
||||
PrivacyList,
|
||||
{From, To, Packet},
|
||||
in]).
|
||||
|
||||
route_message(From, To, Packet) ->
|
||||
LUser = exmpp_jid:lnode(To),
|
||||
LServer = exmpp_jid:ldomain(To),
|
||||
|
Loading…
Reference in New Issue
Block a user