25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-02 16:37:52 +01:00

Merge r1874 from trunk:

* src/mod_shared_roster.erl: Fix bug: a pending subscription
request, and later the requester added to the roster due to a
shared roster group, that request could neither be accepted or
rejected (thanks to Brian Cully)(EJAB-869)

SVN Revision: 1903
This commit is contained in:
Badlop 2009-02-21 09:27:27 +00:00
parent 7c6ccbb744
commit b1f3d56beb
2 changed files with 43 additions and 5 deletions

View File

@ -1,5 +1,10 @@
2009-02-21 Badlop <badlop@process-one.net> 2009-02-21 Badlop <badlop@process-one.net>
* src/mod_shared_roster.erl: Fix bug: a pending subscription
request, and later the requester added to the roster due to a
shared roster group, that request could neither be accepted or
rejected (thanks to Brian Cully)(EJAB-869)
* src/mod_pubsub/mod_pubsub.erl: The table pubsub_node in ejabberd * src/mod_pubsub/mod_pubsub.erl: The table pubsub_node in ejabberd
older than 2.0.2 had indexes for parentid and type. This is not older than 2.0.2 had indexes for parentid and type. This is not
required since ejabberd 2.0.2, so those indexes can be required since ejabberd 2.0.2, so those indexes can be

View File

@ -187,7 +187,24 @@ process_item(RosterItem, Host) ->
%% Check if the list of groups of the new roster item %% Check if the list of groups of the new roster item
%% include at least a new one %% include at least a new one
case lists:subtract(RosterItem#roster.groups, CommonGroups) of case lists:subtract(RosterItem#roster.groups, CommonGroups) of
%% If it doesn't, then remove this user from any
%% existing roster groups.
[] -> [] ->
%% Remove pending subscription by setting it
%% unsubscribed.
Mod = get_roster_mod(ServerFrom),
%% Remove pending out subscription
Mod:out_subscription(UserTo, ServerTo,
jlib:make_jid(UserFrom, ServerFrom, ""),
unsubscribe),
%% Remove pending in subscription
Mod:in_subscription(aaaa, UserFrom, ServerFrom,
jlib:make_jid(UserTo, ServerTo, ""),
unsubscribe, ""),
%% But we're still subscribed, so respond as such.
RosterItem#roster{subscription = both, ask = none}; RosterItem#roster{subscription = both, ask = none};
%% If so, it means the user wants to add that contact %% If so, it means the user wants to add that contact
%% to his personal roster %% to his personal roster
@ -212,11 +229,7 @@ build_roster_record(User1, Server1, User2, Server2, Name2, Groups) ->
set_new_rosteritems(UserFrom, ServerFrom, set_new_rosteritems(UserFrom, ServerFrom,
UserTo, ServerTo, ResourceTo, NameTo, GroupsFrom) -> UserTo, ServerTo, ResourceTo, NameTo, GroupsFrom) ->
Mod = case lists:member(mod_roster_odbc, Mod = get_roster_mod(ServerFrom),
gen_mod:loaded_modules(ServerFrom)) of
true -> mod_roster_odbc;
false -> mod_roster
end,
RIFrom = build_roster_record(UserFrom, ServerFrom, RIFrom = build_roster_record(UserFrom, ServerFrom,
UserTo, ServerTo, NameTo, GroupsFrom), UserTo, ServerTo, NameTo, GroupsFrom),
@ -302,6 +315,18 @@ get_jid_info({Subscription, Groups}, User, Server, JID) ->
in_subscription(Acc, User, Server, JID, Type, _Reason) -> in_subscription(Acc, User, Server, JID, Type, _Reason) ->
process_subscription(in, User, Server, JID, Type, Acc). process_subscription(in, User, Server, JID, Type, Acc).
out_subscription(UserFrom, ServerFrom, JIDTo, unsubscribed) ->
Mod = get_roster_mod(ServerFrom),
%% Remove pending out subscription
#jid{luser = UserTo, lserver = ServerTo} = JIDTo,
JIDFrom = jlib:make_jid(UserFrom, UserTo, ""),
Mod:out_subscription(UserTo, ServerTo, JIDFrom, unsubscribe),
%% Remove pending in subscription
Mod:in_subscription(aaaa, UserFrom, ServerFrom, JIDTo, unsubscribe, ""),
process_subscription(out, UserFrom, ServerFrom, JIDTo, unsubscribed, false);
out_subscription(User, Server, JID, Type) -> out_subscription(User, Server, JID, Type) ->
process_subscription(out, User, Server, JID, Type, false). process_subscription(out, User, Server, JID, Type, false).
@ -910,6 +935,14 @@ shared_roster_group_parse_query(Host, Group, Query) ->
nothing nothing
end. end.
%% Get the roster module for Server.
get_roster_mod(Server) ->
case lists:member(mod_roster_odbc,
gen_mod:loaded_modules(Server)) of
true -> mod_roster_odbc;
false -> mod_roster
end.
get_opt(Opts, Opt, Default) -> get_opt(Opts, Opt, Default) ->
case lists:keysearch(Opt, 1, Opts) of case lists:keysearch(Opt, 1, Opts) of
{value, {_, Val}} -> {value, {_, Val}} ->