Remove _notify_app_services_ephemeral; convert token in on_new_event instead

This is a small effort to reduce the layers of methods we have here.

Also, I've opted to continue converting the RoomStreamToken to an int,
but only for when tracking stream tokens of EDUs. As stated in the
comment, this shouldn't have any gaps as long as we *always* convert to
minimum value.
This commit is contained in:
Andrew Morgan 2021-10-26 14:44:14 +01:00
parent b194d47d7c
commit 2a78554196

View file

@ -182,7 +182,7 @@ class ApplicationServicesHandler:
def notify_interested_services_ephemeral(
self,
stream_key: str,
new_token: int,
new_token: Union[int, RoomStreamToken],
users: Optional[Collection[Union[str, UserID]]] = None,
) -> None:
"""
@ -212,6 +212,13 @@ class ApplicationServicesHandler:
if stream_key not in ("typing_key", "receipt_key", "presence_key"):
return
# Convert new_token from a RoomStreamToken to an int if necessary.
# We just use the minimum stream ordering and ignore the vector clock
# component. This is safe to do as long as we *always* ignore the vector
# clock components.
if isinstance(new_token, RoomStreamToken):
new_token = new_token.stream
services = [
service
for service in self.store.get_app_services()