summary refs log tree commit diff
path: root/synapse/groups/groups_server.py
diff options
context:
space:
mode:
authorWerner Sembach <werner.sembach@fau.de>2019-12-16 13:12:40 +0100
committerAndrew Morgan <1342360+anoadragon453@users.noreply.github.com>2019-12-16 12:12:40 +0000
commit9d173b312cc3ab170de3a7c58ac24778eddf93f6 (patch)
treec42971aa1e2cb4e7d278b5d1d4d8de329feff675 /synapse/groups/groups_server.py
parentDocument Shutdown Room admin API (#6541) (diff)
downloadsynapse-9d173b312cc3ab170de3a7c58ac24778eddf93f6.tar.xz
Automatically delete empty groups/communities (#6453)
Signed-off-by: Werner Sembach <werner.sembach@fau.de>
Diffstat (limited to 'synapse/groups/groups_server.py')
-rw-r--r--synapse/groups/groups_server.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/synapse/groups/groups_server.py b/synapse/groups/groups_server.py
index 29e8ffc295..0ec9be3cb5 100644
--- a/synapse/groups/groups_server.py
+++ b/synapse/groups/groups_server.py
@@ -773,6 +773,11 @@ class GroupsServerHandler(object):
         if not self.hs.is_mine_id(user_id):
             yield self.store.maybe_delete_remote_profile_cache(user_id)
 
+        # Delete group if the last user has left
+        users = yield self.store.get_users_in_group(group_id, include_private=True)
+        if not users:
+            yield self.store.delete_group(group_id)
+
         return {}
 
     @defer.inlineCallbacks