]> granicus.if.org Git - ejabberd/commitdiff
* src/mod_shared_roster.erl: Delete the shared roster group now
authorMickaël Rémond <mickael.remond@process-one.net>
Wed, 5 Jul 2006 08:52:21 +0000 (08:52 +0000)
committerMickaël Rémond <mickael.remond@process-one.net>
Wed, 5 Jul 2006 08:52:21 +0000 (08:52 +0000)
correctly delete its user entries (EJAB-112).

SVN Revision: 583

ChangeLog
src/mod_shared_roster.erl

index 1ac112c018bac93f34ba0d484d65ec715b18ac35..baabf530d7cff6cd91cf073788a3b15381134d72 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@
 
        * src/web/ejabberd_web_admin.erl: More flexible parsing the shared
        roster members list from the configuration form.
+       * src/mod_shared_roster.erl: Delete the shared roster group now
+       correctly delete its user entries.
 
 2006-06-19  Alexey Shchepin  <alexey@sevcom.net>
 
index e6b18c5a4e7689b509c285948520d1b6d5c5d3a5..711cae25fff5925bd59b39afa264eed7440f3c3d 100644 (file)
@@ -197,8 +197,15 @@ create_group(Host, Group, Opts) ->
     mnesia:transaction(F).
 
 delete_group(Host, Group) ->
+    GroupHost = {Group, Host},
     F = fun() ->
-               mnesia:delete({sr_group, {Group, Host}})
+               %% Delete the group ...
+               mnesia:delete({sr_group, GroupHost}),
+               %% ... and its users
+               Users = mnesia:index_read(sr_user, GroupHost, #sr_user.group_host),
+               lists:foreach(fun(UserEntry) ->
+                                     mnesia:delete_object(UserEntry)
+                             end, Users)
        end,
     mnesia:transaction(F).
 
@@ -297,7 +304,8 @@ add_user_to_group(Host, US, Group) ->
     mnesia:transaction(F).
 
 remove_user_from_group(Host, US, Group) ->
-    R = #sr_user{us = US, group_host = {Group, Host}},
+    GroupHost = {Group, Host},
+    R = #sr_user{us = US, group_host = GroupHost},
     F = fun() ->
                mnesia:delete_object(R)
        end,