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

Commit

Permalink
Add a docstring to add_device_change_to_streams and fix some nearby…
Browse files Browse the repository at this point in the history
… types (#11912)
  • Loading branch information
anoadragon453 authored Feb 8, 2022
1 parent 0640f8e commit 3655585
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
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: Collection[str],
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

0 comments on commit 3655585

Please sign in to comment.