diff options
author | Mathieu Velten <matmaul@gmail.com> | 2023-07-02 22:54:34 +0200 |
---|---|---|
committer | Mathieu Velten <matmaul@gmail.com> | 2023-07-02 22:54:34 +0200 |
commit | 648b211d6a1793e939141a417acd9247c510e9d8 (patch) | |
tree | 97f29b16f02df6e9217b2d6cf8671d2760d45862 /synapse | |
parent | Fix error handling (diff) | |
download | synapse-648b211d6a1793e939141a417acd9247c510e9d8.tar.xz |
Fix purge history response format
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/handlers/room.py | 20 | ||||
-rw-r--r-- | synapse/rest/admin/__init__.py | 2 |
2 files changed, 15 insertions, 7 deletions
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index 27e3d1d739..f7f9d9d2f5 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -1845,12 +1845,20 @@ class DeleteStatus: "new_room_id": None, } - def asdict(self) -> JsonDict: - ret = { - "delete_id": self.delete_id, - "status": self.status, - "shutdown_room": self.shutdown_room, - } + def asdict(self, use_purge_history_format: bool = False) -> JsonDict: + if not use_purge_history_format: + ret = { + "delete_id": self.delete_id, + "status": self.status, + "shutdown_room": self.shutdown_room, + } + else: + ret = { + "status": self.status + if self.status == DeleteStatus.STATUS_COMPLETE + or self.status == DeleteStatus.STATUS_FAILED + else "active", + } if self.error: ret["error"] = self.error return ret diff --git a/synapse/rest/admin/__init__.py b/synapse/rest/admin/__init__.py index dbdcef7ae6..0cabdd1dc6 100644 --- a/synapse/rest/admin/__init__.py +++ b/synapse/rest/admin/__init__.py @@ -220,7 +220,7 @@ class PurgeHistoryStatusRestServlet(RestServlet): raise NotFoundError("purge id '%s' not found" % purge_id) # TODO active vs purging etc - return HTTPStatus.OK, purge_status.asdict() + return HTTPStatus.OK, purge_status.asdict(use_purge_history_format=True) ######################################################################################## |