%% Check if the list of groups of the new roster item
%% include at least a new one
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};
%% If so, it means the user wants to add that contact
%% to his personal roster
set_new_rosteritems(UserFrom, ServerFrom,
UserTo, ServerTo, ResourceTo, NameTo, GroupsFrom) ->
- Mod = case lists:member(mod_roster_odbc,
- gen_mod:loaded_modules(ServerFrom)) of
- true -> mod_roster_odbc;
- false -> mod_roster
- end,
+ Mod = get_roster_mod(ServerFrom),
RIFrom = build_roster_record(UserFrom, ServerFrom,
UserTo, ServerTo, NameTo, GroupsFrom),
in_subscription(Acc, User, Server, JID, Type, _Reason) ->
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) ->
process_subscription(out, User, Server, JID, Type, false).
nothing
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) ->
case lists:keysearch(Opt, 1, Opts) of
{value, {_, Val}} ->