mirror of
https://github.com/processone/ejabberd.git
synced 2024-06-28 22:52:27 +02:00
Don't let presence-in privacy rule block a presence subscription using ODBC (EJAB-255)
This commit is contained in:
parent
6e3a9ac4fd
commit
a25c9c5df3
|
@ -554,9 +554,12 @@ get_user_list(_, User, Server) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
%% From is the sender, To is the destination.
|
||||||
|
%% If Dir = out, User@Server is the sender account (From).
|
||||||
|
%% If Dir = in, User@Server is the destination account (To).
|
||||||
check_packet(_, User, Server,
|
check_packet(_, User, Server,
|
||||||
#userlist{list = List, needdb = NeedDb},
|
#userlist{list = List, needdb = NeedDb},
|
||||||
{From, To, {xmlelement, PName, _, _}},
|
{From, To, {xmlelement, PName, Attrs, _}},
|
||||||
Dir) ->
|
Dir) ->
|
||||||
case List of
|
case List of
|
||||||
[] ->
|
[] ->
|
||||||
|
@ -565,48 +568,36 @@ check_packet(_, User, Server,
|
||||||
PType = case PName of
|
PType = case PName of
|
||||||
"message" -> message;
|
"message" -> message;
|
||||||
"iq" -> iq;
|
"iq" -> iq;
|
||||||
"presence" -> presence
|
"presence" ->
|
||||||
|
case xml:get_attr_s("type", Attrs) of
|
||||||
|
%% notification
|
||||||
|
"" -> presence;
|
||||||
|
"unavailable" -> presence;
|
||||||
|
%% subscribe, subscribed, unsubscribe,
|
||||||
|
%% unsubscribed, error, probe, or other
|
||||||
|
_ -> other
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
case {PType, Dir} of
|
PType2 = case {PType, Dir} of
|
||||||
{message, in} ->
|
{message, in} -> message;
|
||||||
LJID = jlib:jid_tolower(From),
|
{iq, in} -> iq;
|
||||||
{Subscription, Groups} =
|
{presence, in} -> presence_in;
|
||||||
case NeedDb of
|
{presence, out} -> presence_out;
|
||||||
true -> ejabberd_hooks:run_fold(roster_get_jid_info, jlib:nameprep(Server), {none, []}, [User, Server, LJID]);
|
{_, _} -> other
|
||||||
false -> {[], []}
|
end,
|
||||||
end,
|
LJID = case Dir of
|
||||||
check_packet_aux(List, message,
|
in -> jlib:jid_tolower(From);
|
||||||
LJID, Subscription, Groups);
|
out -> jlib:jid_tolower(To)
|
||||||
{iq, in} ->
|
end,
|
||||||
LJID = jlib:jid_tolower(From),
|
{Subscription, Groups} =
|
||||||
{Subscription, Groups} =
|
case NeedDb of
|
||||||
case NeedDb of
|
true -> ejabberd_hooks:run_fold(roster_get_jid_info,
|
||||||
true -> ejabberd_hooks:run_fold(roster_get_jid_info, jlib:nameprep(Server), {none, []}, [User, Server, LJID]);
|
jlib:nameprep(Server),
|
||||||
false -> {[], []}
|
{none, []},
|
||||||
end,
|
[User, Server, LJID]);
|
||||||
check_packet_aux(List, iq,
|
false -> {[], []}
|
||||||
LJID, Subscription, Groups);
|
end,
|
||||||
{presence, in} ->
|
check_packet_aux(List, PType2, LJID, Subscription, Groups)
|
||||||
LJID = jlib:jid_tolower(From),
|
|
||||||
{Subscription, Groups} =
|
|
||||||
case NeedDb of
|
|
||||||
true -> ejabberd_hooks:run_fold(roster_get_jid_info, jlib:nameprep(Server), {none, []}, [User, Server, LJID]);
|
|
||||||
false -> {[], []}
|
|
||||||
end,
|
|
||||||
check_packet_aux(List, presence_in,
|
|
||||||
LJID, Subscription, Groups);
|
|
||||||
{presence, out} ->
|
|
||||||
LJID = jlib:jid_tolower(To),
|
|
||||||
{Subscription, Groups} =
|
|
||||||
case NeedDb of
|
|
||||||
true -> ejabberd_hooks:run_fold(roster_get_jid_info, jlib:nameprep(Server), {none, []}, [User, Server, LJID]);
|
|
||||||
false -> {[], []}
|
|
||||||
end,
|
|
||||||
check_packet_aux(List, presence_out,
|
|
||||||
LJID, Subscription, Groups);
|
|
||||||
_ ->
|
|
||||||
allow
|
|
||||||
end
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
check_packet_aux([], _PType, _JID, _Subscription, _Groups) ->
|
check_packet_aux([], _PType, _JID, _Subscription, _Groups) ->
|
||||||
|
@ -646,7 +637,9 @@ is_ptype_match(Item, PType) ->
|
||||||
presence_in ->
|
presence_in ->
|
||||||
Item#listitem.match_presence_in;
|
Item#listitem.match_presence_in;
|
||||||
presence_out ->
|
presence_out ->
|
||||||
Item#listitem.match_presence_out
|
Item#listitem.match_presence_out;
|
||||||
|
other ->
|
||||||
|
false
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user