From 00a923b14ac2282f3ba09e51079daa3220bb7598 Mon Sep 17 00:00:00 2001 From: Alexey Shchepin Date: Tue, 17 Dec 2002 20:49:45 +0000 Subject: *** empty log message *** SVN Revision: 18 --- src/mod_roster.erl | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'src/mod_roster.erl') diff --git a/src/mod_roster.erl b/src/mod_roster.erl index 436e0ba12..f5c03dd49 100644 --- a/src/mod_roster.erl +++ b/src/mod_roster.erl @@ -12,7 +12,9 @@ -export([]). --export([start/0, init/0, process_iq/3]). +-export([start/0, init/0, + process_iq/3, + get_subscription_lists/1]). -include_lib("mnemosyne/include/mnemosyne.hrl"). -include("ejabberd.hrl"). @@ -105,6 +107,8 @@ item_to_xml(Item) -> Attrs3 = case Item#roster.subscription of none -> [{"subscription", "none"} | Attrs2]; + both -> + [{"subscription", "both"} | Attrs2]; remove -> [{"subscription", "remove"} | Attrs2]; _ -> @@ -148,7 +152,8 @@ process_item_set(User, To, XItem) -> xs = []}; [I] -> mnesia:delete_object(I), - I#roster{groups = [], + I#roster{name = "", + groups = [], xattrs = [], xs = []} end, @@ -240,3 +245,31 @@ push_item(User, Resource, From, Item) -> jlib:iq_to_xml(ResIQ)}. +get_subscription_lists(User) -> + LUser = jlib:tolower(User), + F = fun() -> + mnesia:read({roster, LUser}) + end, + case mnesia:transaction(F) of + {atomic, Items} -> + fill_subscription_lists(Items, [], []); + _ -> + {[], []} + end. + +fill_subscription_lists([I | Is], F, T) -> + J = I#roster.jid, + case I#roster.subscription of + both -> + fill_subscription_lists(Is, [J | F], [J | T]); + from -> + fill_subscription_lists(Is, [J | F], T); + to -> + fill_subscription_lists(Is, F, [J | T]); + _ -> + fill_subscription_lists(Is, F, T) + end; +fill_subscription_lists([], F, T) -> + {F, T}. + + -- cgit v1.2.3