Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
fix mypy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dklimpel committed Dec 16, 2021
1 parent c2cc7bc commit d07bf85
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
26 changes: 15 additions & 11 deletions synapse/rest/admin/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
from synapse.http.servlet import RestServlet, parse_integer, parse_string
from synapse.http.site import SynapseRequest
from synapse.rest.admin._base import admin_patterns, assert_requester_is_admin
from synapse.storage.databases.main.transactions import (
DestinationRetryTimings,
DestinationSortOrder,
)
from synapse.storage.databases.main.transactions import DestinationSortOrder
from synapse.types import JsonDict

if TYPE_CHECKING:
Expand Down Expand Up @@ -121,10 +118,19 @@ async def on_GET(
destination
)

if destination_retry_timings is None:
destination_retry_timings = DestinationRetryTimings(
failure_ts=None, retry_last_ts=0, retry_interval=0
)
retry_timing_respone: JsonDict = {}
if destination_retry_timings:
retry_timing_respone = {
"failure_ts": destination_retry_timings.failure_ts,
"retry_last_ts": destination_retry_timings.retry_last_ts,
"retry_interval": destination_retry_timings.retry_interval,
}
else:
retry_timing_respone = {
"failure_ts": None,
"retry_last_ts": 0,
"retry_interval": 0,
}

last_successful_stream_ordering = (
await self._store.get_destination_last_successful_stream_ordering(
Expand All @@ -134,10 +140,8 @@ async def on_GET(

response = {
"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,
**retry_timing_respone,
}

return HTTPStatus.OK, response
9 changes: 5 additions & 4 deletions tests/rest/admin/test_federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,12 @@ def _create_destination(
destination, failure_ts, retry_last_ts, retry_interval
)
)
self.get_success(
self.store.set_destination_last_successful_stream_ordering(
destination, last_successful_stream_ordering
if last_successful_stream_ordering is not None:
self.get_success(
self.store.set_destination_last_successful_stream_ordering(
destination, last_successful_stream_ordering
)
)
)

def _create_destinations(self, number_destinations: int) -> None:
"""Create a number of destinations
Expand Down

0 comments on commit d07bf85

Please sign in to comment.