mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-02 16:37: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
3fce8ed570
commit
1e3faf8bd9
@ -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-10 Badlop <badlop@process-one.net>
|
2009-03-10 Badlop <badlop@process-one.net>
|
||||||
|
|
||||||
* doc/release_notes_2.0.4.txt: Added file for new release
|
* doc/release_notes_2.0.4.txt: Added file for new release
|
||||||
|
@ -1091,21 +1091,16 @@ handle_info({route, From, To, Packet}, StateName, StateData) ->
|
|||||||
Attrs1 = lists:keydelete("type", 1, Attrs),
|
Attrs1 = lists:keydelete("type", 1, Attrs),
|
||||||
{true, [{"type", "unavailable"} | Attrs1], StateData};
|
{true, [{"type", "unavailable"} | Attrs1], StateData};
|
||||||
"subscribe" ->
|
"subscribe" ->
|
||||||
Reason = xml:get_path_s(Packet,[{elem,"status"},cdata]),
|
SRes = is_privacy_allow(From, To, Packet, StateData#state.privacy_list),
|
||||||
SRes = check_privacy_subs(in, subscribe, From, To,
|
|
||||||
Packet, Reason, StateData),
|
|
||||||
{SRes, Attrs, StateData};
|
{SRes, Attrs, StateData};
|
||||||
"subscribed" ->
|
"subscribed" ->
|
||||||
SRes = check_privacy_subs(in, subscribed, From, To,
|
SRes = is_privacy_allow(From, To, Packet, StateData#state.privacy_list),
|
||||||
Packet, "", StateData),
|
|
||||||
{SRes, Attrs, StateData};
|
{SRes, Attrs, StateData};
|
||||||
"unsubscribe" ->
|
"unsubscribe" ->
|
||||||
SRes = check_privacy_subs(in, unsubscribe, From, To,
|
SRes = is_privacy_allow(From, To, Packet, StateData#state.privacy_list),
|
||||||
Packet, "", StateData),
|
|
||||||
{SRes, Attrs, StateData};
|
{SRes, Attrs, StateData};
|
||||||
"unsubscribed" ->
|
"unsubscribed" ->
|
||||||
SRes = check_privacy_subs(in, unsubscribed, From, To,
|
SRes = is_privacy_allow(From, To, Packet, StateData#state.privacy_list),
|
||||||
Packet, "", StateData),
|
|
||||||
{SRes, Attrs, StateData};
|
{SRes, Attrs, StateData};
|
||||||
_ ->
|
_ ->
|
||||||
case ejabberd_hooks:run_fold(
|
case ejabberd_hooks:run_fold(
|
||||||
@ -1628,35 +1623,18 @@ presence_track(From, To, Packet, StateData) ->
|
|||||||
pres_a = A}
|
pres_a = A}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% Check privacy rules for subscription requests and call the roster storage
|
%% Check if privacy rules allow this delivery
|
||||||
check_privacy_subs(Dir, Type, From, To, Packet, Reason, StateData) ->
|
is_privacy_allow(From, To, Packet, PrivacyList) ->
|
||||||
case is_privacy_allow(From, To, Dir, Packet, StateData) of
|
User = To#jid.user,
|
||||||
true ->
|
Server = To#jid.server,
|
||||||
ejabberd_hooks:run_fold(
|
allow == ejabberd_hooks:run_fold(
|
||||||
roster_in_subscription,
|
privacy_check_packet, Server,
|
||||||
To#jid.lserver,
|
allow,
|
||||||
false,
|
[User,
|
||||||
[To#jid.user, To#jid.server, From, Type, Reason]),
|
Server,
|
||||||
true;
|
PrivacyList,
|
||||||
false ->
|
{From, To, Packet},
|
||||||
false
|
in]).
|
||||||
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) ->
|
presence_broadcast(StateData, From, JIDSet, Packet) ->
|
||||||
lists:foreach(fun(JID) ->
|
lists:foreach(fun(JID) ->
|
||||||
|
@ -59,6 +59,7 @@
|
|||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
-include("jlib.hrl").
|
-include("jlib.hrl").
|
||||||
-include("ejabberd_ctl.hrl").
|
-include("ejabberd_ctl.hrl").
|
||||||
|
-include("mod_privacy.hrl").
|
||||||
|
|
||||||
-record(session, {sid, usr, us, priority, info}).
|
-record(session, {sid, usr, us, priority, info}).
|
||||||
-record(state, {}).
|
-record(state, {}).
|
||||||
@ -381,13 +382,40 @@ do_route(From, To, Packet) ->
|
|||||||
{Pass, _Subsc} =
|
{Pass, _Subsc} =
|
||||||
case xml:get_attr_s("type", Attrs) of
|
case xml:get_attr_s("type", Attrs) of
|
||||||
"subscribe" ->
|
"subscribe" ->
|
||||||
{true, true};
|
Reason = xml:get_path_s(
|
||||||
|
Packet,
|
||||||
|
[{elem, "status"}, cdata]),
|
||||||
|
{is_privacy_allow(From, To, Packet) andalso
|
||||||
|
ejabberd_hooks:run_fold(
|
||||||
|
roster_in_subscription,
|
||||||
|
LServer,
|
||||||
|
false,
|
||||||
|
[User, Server, From, subscribe, Reason]),
|
||||||
|
true};
|
||||||
"subscribed" ->
|
"subscribed" ->
|
||||||
{true, true};
|
{is_privacy_allow(From, To, Packet) andalso
|
||||||
|
ejabberd_hooks:run_fold(
|
||||||
|
roster_in_subscription,
|
||||||
|
LServer,
|
||||||
|
false,
|
||||||
|
[User, Server, From, subscribed, ""]),
|
||||||
|
true};
|
||||||
"unsubscribe" ->
|
"unsubscribe" ->
|
||||||
{true, true};
|
{is_privacy_allow(From, To, Packet) andalso
|
||||||
|
ejabberd_hooks:run_fold(
|
||||||
|
roster_in_subscription,
|
||||||
|
LServer,
|
||||||
|
false,
|
||||||
|
[User, Server, From, unsubscribe, ""]),
|
||||||
|
true};
|
||||||
"unsubscribed" ->
|
"unsubscribed" ->
|
||||||
{true, true};
|
{is_privacy_allow(From, To, Packet) andalso
|
||||||
|
ejabberd_hooks:run_fold(
|
||||||
|
roster_in_subscription,
|
||||||
|
LServer,
|
||||||
|
false,
|
||||||
|
[User, Server, From, unsubscribed, ""]),
|
||||||
|
true};
|
||||||
_ ->
|
_ ->
|
||||||
{true, false}
|
{true, false}
|
||||||
end,
|
end,
|
||||||
@ -446,6 +474,31 @@ do_route(From, To, Packet) ->
|
|||||||
end
|
end
|
||||||
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 = To#jid.user,
|
||||||
|
Server = To#jid.server,
|
||||||
|
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 = To#jid.user,
|
||||||
|
Server = To#jid.server,
|
||||||
|
allow == ejabberd_hooks:run_fold(
|
||||||
|
privacy_check_packet, Server,
|
||||||
|
allow,
|
||||||
|
[User,
|
||||||
|
Server,
|
||||||
|
PrivacyList,
|
||||||
|
{From, To, Packet},
|
||||||
|
in]).
|
||||||
|
|
||||||
route_message(From, To, Packet) ->
|
route_message(From, To, Packet) ->
|
||||||
LUser = To#jid.luser,
|
LUser = To#jid.luser,
|
||||||
LServer = To#jid.lserver,
|
LServer = To#jid.lserver,
|
||||||
|
Loading…
Reference in New Issue
Block a user