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

Add a docstring to add_device_change_to_streams and fix some nearby types #11912

Merged
merged 3 commits into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
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/11912.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Various refactors to the application service notifier code.
22 changes: 16 additions & 6 deletions synapse/storage/databases/main/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -1496,13 +1496,23 @@ def _update_remote_device_list_cache_txn(
)

async def add_device_change_to_streams(
self, user_id: str, device_ids: Collection[str], hosts: List[str]
) -> int:
self, user_id: str, device_ids: Collection[str], hosts: Collection[str]
) -> Optional[int]:
"""Persist that a user's devices have been updated, and which hosts
(if any) should be poked.

Args:
user_id: The ID of the user whose device changed.
device_ids: The IDs of any changed devices. If empty, this function will
return None.
hosts: The remote destinations that should be notified of the change.

Returns:
The maximum stream ID of device list updates that were added to the database, or
None if no updates were added.
"""
if not device_ids:
return
return None

async with self._device_list_id_gen.get_next_mult(
len(device_ids)
Expand Down Expand Up @@ -1573,11 +1583,11 @@ def _add_device_outbound_poke_to_stream_txn(
self,
txn: LoggingTransaction,
user_id: str,
device_ids: Collection[str],
hosts: List[str],
device_ids: Iterable[str],
hosts: Iterable[str],
anoadragon453 marked this conversation as resolved.
Show resolved Hide resolved
stream_ids: List[str],
context: Dict[str, str],
):
) -> None:
for host in hosts:
txn.call_after(
self._device_list_federation_stream_cache.entity_has_changed,
Expand Down