6565from synapse .replication .slave .storage .room import RoomStore
6666from synapse .replication .slave .storage .transactions import SlavedTransactionStore
6767from synapse .replication .tcp .client import ReplicationClientHandler
68- from synapse .replication .tcp .streams ._base import (
68+ from synapse .replication .tcp .streams import (
69+ AccountDataStream ,
6970 DeviceListsStream ,
71+ GroupServerStream ,
72+ PresenceStream ,
73+ PushersStream ,
74+ PushRulesStream ,
7075 ReceiptsStream ,
76+ TagAccountDataStream ,
7177 ToDeviceStream ,
78+ TypingStream ,
79+ )
80+ from synapse .replication .tcp .streams .events import (
81+ EventsStream ,
82+ EventsStreamEventRow ,
83+ EventsStreamRow ,
7284)
73- from synapse .replication .tcp .streams .events import EventsStreamEventRow , EventsStreamRow
7485from synapse .rest .admin import register_servlets_for_media_repo
7586from synapse .rest .client .v1 import events
7687from synapse .rest .client .v1 .initial_sync import InitialSyncRestServlet
@@ -632,7 +643,7 @@ async def process_and_notify(self, stream_name, token, rows):
632643 if self .send_handler :
633644 self .send_handler .process_replication_rows (stream_name , token , rows )
634645
635- if stream_name == "events" :
646+ if stream_name == EventsStream . NAME :
636647 # We shouldn't get multiple rows per token for events stream, so
637648 # we don't need to optimise this for multiple rows.
638649 for row in rows :
@@ -655,44 +666,44 @@ async def process_and_notify(self, stream_name, token, rows):
655666 )
656667
657668 await self .pusher_pool .on_new_notifications (token , token )
658- elif stream_name == "push_rules" :
669+ elif stream_name == PushRulesStream . NAME :
659670 self .notifier .on_new_event (
660671 "push_rules_key" , token , users = [row .user_id for row in rows ]
661672 )
662- elif stream_name in ("account_data" , "tag_account_data" ):
673+ elif stream_name in (AccountDataStream . NAME , TagAccountDataStream . NAME ):
663674 self .notifier .on_new_event (
664675 "account_data_key" , token , users = [row .user_id for row in rows ]
665676 )
666- elif stream_name == "receipts" :
677+ elif stream_name == ReceiptsStream . NAME :
667678 self .notifier .on_new_event (
668679 "receipt_key" , token , rooms = [row .room_id for row in rows ]
669680 )
670681 await self .pusher_pool .on_new_receipts (
671682 token , token , {row .room_id for row in rows }
672683 )
673- elif stream_name == "typing" :
684+ elif stream_name == TypingStream . NAME :
674685 self .typing_handler .process_replication_rows (token , rows )
675686 self .notifier .on_new_event (
676687 "typing_key" , token , rooms = [row .room_id for row in rows ]
677688 )
678- elif stream_name == "to_device" :
689+ elif stream_name == ToDeviceStream . NAME :
679690 entities = [row .entity for row in rows if row .entity .startswith ("@" )]
680691 if entities :
681692 self .notifier .on_new_event ("to_device_key" , token , users = entities )
682- elif stream_name == "device_lists" :
693+ elif stream_name == DeviceListsStream . NAME :
683694 all_room_ids = set ()
684695 for row in rows :
685696 if row .entity .startswith ("@" ):
686697 room_ids = await self .store .get_rooms_for_user (row .entity )
687698 all_room_ids .update (room_ids )
688699 self .notifier .on_new_event ("device_list_key" , token , rooms = all_room_ids )
689- elif stream_name == "presence" :
700+ elif stream_name == PresenceStream . NAME :
690701 await self .presence_handler .process_replication_rows (token , rows )
691- elif stream_name == "receipts" :
702+ elif stream_name == GroupServerStream . NAME :
692703 self .notifier .on_new_event (
693704 "groups_key" , token , users = [row .user_id for row in rows ]
694705 )
695- elif stream_name == "pushers" :
706+ elif stream_name == PushersStream . NAME :
696707 for row in rows :
697708 if row .deleted :
698709 self .stop_pusher (row .user_id , row .app_id , row .pushkey )
0 commit comments