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

Minor typing fixes #12034

Merged
merged 2 commits into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/12034.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Minor typing fixes.
11 changes: 6 additions & 5 deletions synapse/federation/sender/per_destination_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,9 @@ async def _catch_up_transmission_loop(self) -> None:
)
)

if self._last_successful_stream_ordering is None:
last_successful_stream_ordering = self._last_successful_stream_ordering

if last_successful_stream_ordering is None:
# if it's still None, then this means we don't have the information
# in our database ­ we haven't successfully sent a PDU to this server
# (at least since the introduction of the feature tracking
Expand All @@ -394,16 +396,15 @@ async def _catch_up_transmission_loop(self) -> None:
# get at most 50 catchup room/PDUs
while True:
event_ids = await self._store.get_catch_up_room_event_ids(
self._destination,
self._last_successful_stream_ordering,
self._destination, last_successful_stream_ordering
)

if not event_ids:
# No more events to catch up on, but we can't ignore the chance
# of a race condition, so we check that no new events have been
# skipped due to us being in catch-up mode

if self._catchup_last_skipped > self._last_successful_stream_ordering:
if self._catchup_last_skipped > last_successful_stream_ordering:
# another event has been skipped because we were in catch-up mode
continue

Expand Down Expand Up @@ -470,7 +471,7 @@ async def _catch_up_transmission_loop(self) -> None:
# offline
if (
p.internal_metadata.stream_ordering
< self._last_successful_stream_ordering
< last_successful_stream_ordering
):
continue

Expand Down
10 changes: 6 additions & 4 deletions synapse/handlers/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,10 +550,11 @@ async def create_event(

if event_dict["type"] == EventTypes.Create and event_dict["state_key"] == "":
room_version_id = event_dict["content"]["room_version"]
room_version_obj = KNOWN_ROOM_VERSIONS.get(room_version_id)
if not room_version_obj:
maybe_room_version_obj = KNOWN_ROOM_VERSIONS.get(room_version_id)
if not maybe_room_version_obj:
# this can happen if support is withdrawn for a room version
raise UnsupportedRoomVersionError(room_version_id)
room_version_obj = maybe_room_version_obj
else:
try:
room_version_obj = await self.store.get_room_version(
Expand Down Expand Up @@ -1145,12 +1146,13 @@ async def handle_new_client_event(
room_version_id = event.content.get(
"room_version", RoomVersions.V1.identifier
)
room_version_obj = KNOWN_ROOM_VERSIONS.get(room_version_id)
if not room_version_obj:
maybe_room_version_obj = KNOWN_ROOM_VERSIONS.get(room_version_id)
if not maybe_room_version_obj:
raise UnsupportedRoomVersionError(
"Attempt to create a room with unsupported room version %s"
% (room_version_id,)
)
room_version_obj = maybe_room_version_obj
else:
room_version_obj = await self.store.get_room_version(event.room_id)

Expand Down
6 changes: 3 additions & 3 deletions synapse/handlers/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,12 @@ async def register_user(
if fail_count > 10:
raise SynapseError(500, "Unable to find a suitable guest user ID")

localpart = await self.store.generate_user_id()
user = UserID(localpart, self.hs.hostname)
generated_localpart = await self.store.generate_user_id()
user = UserID(generated_localpart, self.hs.hostname)
user_id = user.to_string()
self.check_user_id_not_appservice_exclusive(user_id)
if generate_display_name:
default_display_name = localpart
default_display_name = generated_localpart
try:
await self.register_with_store(
user_id=user_id,
Expand Down