summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2021-10-26 12:03:26 +0100
committerAndrew Morgan <andrew@amorgan.xyz>2021-10-26 12:03:29 +0100
commitb194d47d7c69a5f61f2b3291fdbaece7765c6f00 (patch)
tree256b4a9572b509b9bf7b3d352c8fa8914d9f6d42
parentAdd missing return type hints for stream ids (diff)
downloadsynapse-b194d47d7c69a5f61f2b3291fdbaece7765c6f00.tar.xz
wip - use int everywhere instead
-rw-r--r--synapse/handlers/appservice.py2
-rw-r--r--synapse/notifier.py41
2 files changed, 11 insertions, 32 deletions
diff --git a/synapse/handlers/appservice.py b/synapse/handlers/appservice.py

index 1ed079a374..6cad82f542 100644 --- a/synapse/handlers/appservice.py +++ b/synapse/handlers/appservice.py
@@ -203,7 +203,7 @@ class ApplicationServicesHandler: Appservices will only receive ephemeral events that fall within their registered user and room namespaces. - new_token: The latest stream token. + new_token: The stream token of the event. users: The users that should be informed of the new event, if any. """ if not self.notify_appservices: diff --git a/synapse/notifier.py b/synapse/notifier.py
index 70c1498355..dc6c3fd8b2 100644 --- a/synapse/notifier.py +++ b/synapse/notifier.py
@@ -271,7 +271,7 @@ class Notifier: self, event: EventBase, event_pos: PersistedEventPosition, - max_room_stream_token: RoomStreamToken, + max_room_stream_token: int, extra_users: Optional[Collection[UserID]] = None, ): """Unwraps event and calls `on_new_room_event_args`.""" @@ -374,30 +374,6 @@ class Notifier: except Exception: logger.exception("Error notifying application services of event") - def _notify_app_services_ephemeral( - self, - stream_key: str, - new_token: Union[int, RoomStreamToken], - users: Optional[Collection[Union[str, UserID]]] = None, - ) -> None: - """Notify application services of ephemeral event activity. - - Args: - stream_key: The stream the event came from. - new_token: The value of the new stream token. - users: The users that should be informed of the new event, if any. - """ - try: - # Convert new_token from a RoomStreamToken to an int if necessary - if isinstance(new_token, RoomStreamToken): - new_token = new_token.stream - - self.appservice_handler.notify_interested_services_ephemeral( - stream_key, new_token, users or [] - ) - except Exception: - logger.exception("Error notifying application services of event") - def _notify_pusher_pool(self, max_room_stream_token: RoomStreamToken): try: self._pusher_pool.on_new_notifications(max_room_stream_token) @@ -407,7 +383,7 @@ class Notifier: def on_new_event( self, stream_key: str, - new_token: Union[int, RoomStreamToken], + new_token: int, users: Optional[Collection[Union[str, UserID]]] = None, rooms: Optional[Collection[str]] = None, ) -> None: @@ -460,11 +436,14 @@ class Notifier: self.notify_replication() # Notify appservices - self._notify_app_services_ephemeral( - stream_key, - new_token, - users, - ) + try: + self.appservice_handler.notify_interested_services_ephemeral( + stream_key, + new_token, + users, + ) + except Exception: + logger.exception("Error notifying application services of event") def on_new_replication_data(self) -> None: """Used to inform replication listeners that something has happened