diff --git a/synapse/appservice/__init__.py b/synapse/appservice/__init__.py index d4a2f02fc259..3862d9c08f38 100644 --- a/synapse/appservice/__init__.py +++ b/synapse/appservice/__init__.py @@ -297,7 +297,7 @@ def get_groups_for_user(self, user_id: str) -> Iterable[str]: user_id: The ID of the user. Returns: - iterable: an iterable that yields group_id strings. + An iterable that yields group_id strings. """ return ( regex_obj["group_id"] diff --git a/synapse/appservice/scheduler.py b/synapse/appservice/scheduler.py index a55bc119cb89..ad3c408519ee 100644 --- a/synapse/appservice/scheduler.py +++ b/synapse/appservice/scheduler.py @@ -49,7 +49,7 @@ components. """ import logging -from typing import List, Optional +from typing import List from synapse.appservice import ApplicationService, ApplicationServiceState from synapse.events import EventBase @@ -120,7 +120,7 @@ def _start_background_request(self, service): "as-sender-%s" % (service.id,), self._send_request, service ) - def enqueue_event(self, service, event): + def enqueue_event(self, service: ApplicationService, event: EventBase): self.queued_events.setdefault(service.id, []).append(event) self._start_background_request(service) @@ -177,7 +177,7 @@ async def send( self, service: ApplicationService, events: List[EventBase], - ephemeral: Optional[JsonDict] = None, + ephemeral: List[JsonDict] = [], ): try: txn = await self.store.create_appservice_txn( diff --git a/synapse/storage/databases/main/receipts.py b/synapse/storage/databases/main/receipts.py index dbb4887985ca..5cdf16521c3f 100644 --- a/synapse/storage/databases/main/receipts.py +++ b/synapse/storage/databases/main/receipts.py @@ -23,6 +23,7 @@ from synapse.storage._base import SQLBaseStore, db_to_json, make_in_list_sql_clause from synapse.storage.database import DatabasePool from synapse.storage.util.id_generators import StreamIdGenerator +from synapse.types import JsonDict from synapse.util import json_encoder from synapse.util.async_helpers import ObservableDeferred from synapse.util.caches.descriptors import cached, cachedList @@ -277,7 +278,18 @@ def f(txn): @cached(num_args=2,) async def get_linearized_receipts_for_all_rooms( self, to_key: int, from_key: Optional[int] = None - ): + ) -> Dict[str, JsonDict]: + """Get receipts for all rooms between two stream_ids. + + Args: + to_key: Max stream id to fetch receipts upto. + from_key: Min stream id to fetch receipts from. None fetches + from the start. + + Returns: + A dictionary of roomids to a list of receipts. + """ + def f(txn): if from_key: sql = """