summary refs log tree commit diff
path: root/synapse/rest/admin/federation.py
diff options
context:
space:
mode:
authorDirk Klimpel <5740567+dklimpel@users.noreply.github.com>2022-01-05 20:46:50 +0100
committerGitHub <noreply@github.com>2022-01-05 14:46:50 -0500
commit3b51c763ba5601e155e3e27a46cddf0370da83eb (patch)
treeada08d68211cceeb2107666caf1328a6380101a0 /synapse/rest/admin/federation.py
parentRun `pyupgrade --py37-plus --keep-percent-format` on Synapse (#11685) (diff)
downloadsynapse-3b51c763ba5601e155e3e27a46cddf0370da83eb.tar.xz
Fix get federation status of destination if no error occured (#11593)
Diffstat (limited to 'synapse/rest/admin/federation.py')
-rw-r--r--synapse/rest/admin/federation.py26
1 files changed, 19 insertions, 7 deletions
diff --git a/synapse/rest/admin/federation.py b/synapse/rest/admin/federation.py
index 50d88c9109..8cd3fa189e 100644
--- a/synapse/rest/admin/federation.py
+++ b/synapse/rest/admin/federation.py
@@ -111,25 +111,37 @@ class DestinationsRestServlet(RestServlet):
     ) -> Tuple[int, JsonDict]:
         await assert_requester_is_admin(self._auth, request)
 
+        if not await self._store.is_destination_known(destination):
+            raise NotFoundError("Unknown destination")
+
         destination_retry_timings = await self._store.get_destination_retry_timings(
             destination
         )
 
-        if not destination_retry_timings:
-            raise NotFoundError("Unknown destination")
-
         last_successful_stream_ordering = (
             await self._store.get_destination_last_successful_stream_ordering(
                 destination
             )
         )
 
-        response = {
+        response: JsonDict = {
             "destination": destination,
-            "failure_ts": destination_retry_timings.failure_ts,
-            "retry_last_ts": destination_retry_timings.retry_last_ts,
-            "retry_interval": destination_retry_timings.retry_interval,
             "last_successful_stream_ordering": last_successful_stream_ordering,
         }
 
+        if destination_retry_timings:
+            response = {
+                **response,
+                "failure_ts": destination_retry_timings.failure_ts,
+                "retry_last_ts": destination_retry_timings.retry_last_ts,
+                "retry_interval": destination_retry_timings.retry_interval,
+            }
+        else:
+            response = {
+                **response,
+                "failure_ts": None,
+                "retry_last_ts": 0,
+                "retry_interval": 0,
+            }
+
         return HTTPStatus.OK, response