summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndrew Morgan <1342360+anoadragon453@users.noreply.github.com>2022-02-08 10:52:22 +0000
committerGitHub <noreply@github.com>2022-02-08 10:52:22 +0000
commit3655585e85bfebd9165151d9d69fd907d65d6db0 (patch)
treecda3bb1a756c6e1ad975ed11b0106f23e9601508
parentAdd a callback to allow modules to deny 3PID (#11854) (diff)
downloadsynapse-3655585e85bfebd9165151d9d69fd907d65d6db0.tar.xz
Add a docstring to `add_device_change_to_streams` and fix some nearby types (#11912)
-rw-r--r--changelog.d/11912.misc1
-rw-r--r--synapse/storage/databases/main/devices.py22
2 files changed, 17 insertions, 6 deletions
diff --git a/changelog.d/11912.misc b/changelog.d/11912.misc
new file mode 100644

index 0000000000..805588c2e9 --- /dev/null +++ b/changelog.d/11912.misc
@@ -0,0 +1 @@ +Various refactors to the application service notifier code. \ No newline at end of file diff --git a/synapse/storage/databases/main/devices.py b/synapse/storage/databases/main/devices.py
index b2a5cd9a65..8d845fe951 100644 --- a/synapse/storage/databases/main/devices.py +++ b/synapse/storage/databases/main/devices.py
@@ -1496,13 +1496,23 @@ class DeviceStore(DeviceWorkerStore, DeviceBackgroundUpdateStore): ) 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) @@ -1573,11 +1583,11 @@ class DeviceStore(DeviceWorkerStore, DeviceBackgroundUpdateStore): 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,