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

Commit 3655585

Browse files
Add a docstring to add_device_change_to_streams and fix some nearby types (#11912)
1 parent 0640f8e commit 3655585

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

changelog.d/11912.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Various refactors to the application service notifier code.

synapse/storage/databases/main/devices.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,13 +1496,23 @@ def _update_remote_device_list_cache_txn(
14961496
)
14971497

14981498
async def add_device_change_to_streams(
1499-
self, user_id: str, device_ids: Collection[str], hosts: List[str]
1500-
) -> int:
1499+
self, user_id: str, device_ids: Collection[str], hosts: Collection[str]
1500+
) -> Optional[int]:
15011501
"""Persist that a user's devices have been updated, and which hosts
15021502
(if any) should be poked.
1503+
1504+
Args:
1505+
user_id: The ID of the user whose device changed.
1506+
device_ids: The IDs of any changed devices. If empty, this function will
1507+
return None.
1508+
hosts: The remote destinations that should be notified of the change.
1509+
1510+
Returns:
1511+
The maximum stream ID of device list updates that were added to the database, or
1512+
None if no updates were added.
15031513
"""
15041514
if not device_ids:
1505-
return
1515+
return None
15061516

15071517
async with self._device_list_id_gen.get_next_mult(
15081518
len(device_ids)
@@ -1573,11 +1583,11 @@ def _add_device_outbound_poke_to_stream_txn(
15731583
self,
15741584
txn: LoggingTransaction,
15751585
user_id: str,
1576-
device_ids: Collection[str],
1577-
hosts: List[str],
1586+
device_ids: Iterable[str],
1587+
hosts: Collection[str],
15781588
stream_ids: List[str],
15791589
context: Dict[str, str],
1580-
):
1590+
) -> None:
15811591
for host in hosts:
15821592
txn.call_after(
15831593
self._device_list_federation_stream_cache.entity_has_changed,

0 commit comments

Comments
 (0)