From 1f077a566c801065d1f8909fbd16f5433c179948 Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Fri, 12 Dec 2025 17:30:18 +0000 Subject: [PATCH] Various tidying (no semantic change) --- synapse/federation/sender/__init__.py | 32 ++++++++++++++------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/synapse/federation/sender/__init__.py b/synapse/federation/sender/__init__.py index 3c977d7cf6..daeca71c7f 100644 --- a/synapse/federation/sender/__init__.py +++ b/synapse/federation/sender/__init__.py @@ -527,7 +527,7 @@ class FederationSender(AbstractFederationSender): ) -> None: sticky_event_ids = await self.store.get_sticky_event_ids_sent_by_self( room_id, - 0, + from_stream_pos=0, ) sticky_events = await self.store.get_events_as_list(sticky_event_ids) @@ -540,8 +540,7 @@ class FederationSender(AbstractFederationSender): and not ev.internal_metadata.is_outlier() ] # order by stream ordering so we present things in the right timeline order on the receiver - sticky_events = sorted( - sticky_events, + sticky_events.sort( key=lambda ev: ev.internal_metadata.stream_ordering or 0, # not possible to be 0 ) @@ -555,18 +554,21 @@ class FederationSender(AbstractFederationSender): filter_out_erased_senders=True, filter_out_remote_partial_state_events=True, ) - if sticky_events: - logger.info( - "sending %d sticky events to newly joined server %s in room %s", - len(sticky_events), - new_server, - room_id, - ) - # we don't track that we sent up to this stream position since it won't make any difference - # since notify_new_server_joined is only called initially. - await self._transaction_manager.send_new_transaction( - new_server, sticky_events, [] - ) + + if not sticky_events: + return + + logger.info( + "sending %d sticky events to newly joined server %s in room %s", + len(sticky_events), + new_server, + room_id, + ) + # we don't track that we sent up to this stream position since it won't make any difference + # since notify_new_server_joined is only called initially. + await self._transaction_manager.send_new_transaction( + new_server, sticky_events, [] + ) def notify_new_events(self, max_token: RoomStreamToken) -> None: """This gets called when we have some new events we might want to