summary refs log tree commit diff
path: root/synapse/handlers/pagination.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-08-22 13:41:57 +0100
committerErik Johnston <erik@matrix.org>2019-08-22 13:41:57 +0100
commit1e4b4d85e7f4604d0617bba01b279f3dc2ced1d2 (patch)
tree99baa32e4bc755be4c21f5d711b07a86bfff8020 /synapse/handlers/pagination.py
parentMake changelog entry be a feature (diff)
parentMerge pull request #5850 from matrix-org/erikj/retry_well_known_on_fail (diff)
downloadsynapse-1e4b4d85e7f4604d0617bba01b279f3dc2ced1d2.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into erikj/reliable_lookups
Diffstat (limited to 'synapse/handlers/pagination.py')
-rw-r--r--synapse/handlers/pagination.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/synapse/handlers/pagination.py b/synapse/handlers/pagination.py
index d83aab3f74..5744f4579d 100644
--- a/synapse/handlers/pagination.py
+++ b/synapse/handlers/pagination.py
@@ -70,6 +70,7 @@ class PaginationHandler(object):
         self.auth = hs.get_auth()
         self.store = hs.get_datastore()
         self.clock = hs.get_clock()
+        self._server_name = hs.hostname
 
         self.pagination_lock = ReadWriteLock()
         self._purges_in_progress_by_room = set()
@@ -153,6 +154,22 @@ class PaginationHandler(object):
         """
         return self._purges_by_id.get(purge_id)
 
+    async def purge_room(self, room_id):
+        """Purge the given room from the database"""
+        with (await self.pagination_lock.write(room_id)):
+            # check we know about the room
+            await self.store.get_room_version(room_id)
+
+            # first check that we have no users in this room
+            joined = await defer.maybeDeferred(
+                self.store.is_host_joined, room_id, self._server_name
+            )
+
+            if joined:
+                raise SynapseError(400, "Users are still joined to this room")
+
+            await self.store.purge_room(room_id)
+
     @defer.inlineCallbacks
     def get_messages(
         self,