aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mod_roster_odbc.erl16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/mod_roster_odbc.erl b/src/mod_roster_odbc.erl
index 936d3cff2..b713a0aab 100644
--- a/src/mod_roster_odbc.erl
+++ b/src/mod_roster_odbc.erl
@@ -249,6 +249,11 @@ get_roster(LUser, LServer) ->
_ ->
[]
end,
+ GroupsDict =
+ lists:foldl(
+ fun({J, G}, Acc) ->
+ dict:append(J, G, Acc)
+ end, dict:new(), JIDGroups),
RItems = lists:flatmap(
fun(I) ->
case raw_to_record(LServer, I) of
@@ -257,12 +262,11 @@ get_roster(LUser, LServer) ->
[];
R ->
SJID = jlib:jid_to_string(R#roster.jid),
- Groups = lists:flatmap(
- fun({S, G}) when S == SJID ->
- [G];
- (_) ->
- []
- end, JIDGroups),
+ Groups =
+ case dict:find(SJID, GroupsDict) of
+ {ok, Gs} -> Gs;
+ error -> []
+ end,
[R#roster{groups = Groups}]
end
end, Items),