aboutsummaryrefslogtreecommitdiff
path: root/src/mod_roster.erl
diff options
context:
space:
mode:
authorAlexey Shchepin <alexey@process-one.net>2002-12-17 20:49:45 +0000
committerAlexey Shchepin <alexey@process-one.net>2002-12-17 20:49:45 +0000
commit00a923b14ac2282f3ba09e51079daa3220bb7598 (patch)
tree30021b9150769ff360b2de22b19a1a31102a1faf /src/mod_roster.erl
parent*** empty log message *** (diff)
*** empty log message ***
SVN Revision: 18
Diffstat (limited to 'src/mod_roster.erl')
-rw-r--r--src/mod_roster.erl37
1 files changed, 35 insertions, 2 deletions
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}.
+
+