diff options
author | Andrew Morgan <andrew@amorgan.xyz> | 2020-02-21 11:01:08 +0000 |
---|---|---|
committer | Andrew Morgan <andrew@amorgan.xyz> | 2020-02-21 11:01:08 +0000 |
commit | 5a60e070fe676f522650f29da65113fc6e054ec0 (patch) | |
tree | 66c6acf1c95936c75510f18133f235d01b6dbefa /synapse/handlers/pagination.py | |
parent | Improve error msg when key-fetch fails (#5896) (diff) | |
parent | Servlet to purge old rooms (#5845) (diff) | |
download | synapse-5a60e070fe676f522650f29da65113fc6e054ec0.tar.xz |
Servlet to purge old rooms (#5845)
Diffstat (limited to 'synapse/handlers/pagination.py')
-rw-r--r-- | synapse/handlers/pagination.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/synapse/handlers/pagination.py b/synapse/handlers/pagination.py index 6711ced51a..d8c3feff16 100644 --- a/synapse/handlers/pagination.py +++ b/synapse/handlers/pagination.py @@ -73,6 +73,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() @@ -261,6 +262,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, |