diff options
author | Will Hunt <will@half-shot.uk> | 2020-10-13 10:36:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-13 10:36:48 +0100 |
commit | 8a7172ff268458184266906dd81ae4858795ea6a (patch) | |
tree | 7f032bdba4193f9a292bfe77ee15446ceadda1be | |
parent | stores can be None (diff) | |
download | synapse-8a7172ff268458184266906dd81ae4858795ea6a.tar.xz |
Apply suggestions from code review
Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
-rw-r--r-- | changelog.d/8437.feature | 2 | ||||
-rw-r--r-- | synapse/appservice/__init__.py | 6 | ||||
-rw-r--r-- | synapse/appservice/scheduler.py | 4 | ||||
-rw-r--r-- | synapse/handlers/appservice.py | 4 | ||||
-rw-r--r-- | synapse/storage/databases/main/appservice.py | 3 |
5 files changed, 14 insertions, 5 deletions
diff --git a/changelog.d/8437.feature b/changelog.d/8437.feature index 86f6577748..4abcccb326 100644 --- a/changelog.d/8437.feature +++ b/changelog.d/8437.feature @@ -1 +1 @@ -Implement [MSC2409](https://github.com/matrix-org/matrix-doc/pull/2409) to send typing, read receipts and presence events to appservices. \ No newline at end of file +Implement [MSC2409](https://github.com/matrix-org/matrix-doc/pull/2409) to send typing, read receipts, and presence events to appservices. diff --git a/synapse/appservice/__init__.py b/synapse/appservice/__init__.py index 078fefa00b..8052f3bc6d 100644 --- a/synapse/appservice/__init__.py +++ b/synapse/appservice/__init__.py @@ -172,6 +172,8 @@ class ApplicationService: Args: room_id: The room to check. + store: The datastore to query. + Returns: True if this service would like to know about this room. """ @@ -207,6 +209,8 @@ class ApplicationService: Args: event: The event to check. + store: The datastore to query. + Returns: True if this service would like to know about this event. """ @@ -233,6 +237,8 @@ class ApplicationService: Args: user_id: The user to check. + store: The datastore to query. + Returns: True if this service would like to know about presence for this user. """ diff --git a/synapse/appservice/scheduler.py b/synapse/appservice/scheduler.py index 2f0729a534..bf294daf1c 100644 --- a/synapse/appservice/scheduler.py +++ b/synapse/appservice/scheduler.py @@ -89,7 +89,7 @@ class ApplicationServiceScheduler: self.queuer.enqueue(service, event) def submit_ephemeral_events_for_as( - self, service: ApplicationService, events: List[Any] + self, service: ApplicationService, events: List[JsonDict] ): self.queuer.enqueue_ephemeral(service, events) @@ -124,7 +124,7 @@ class _ServiceQueuer: self.queued_events.setdefault(service.id, []).append(event) self._start_background_request(service) - def enqueue_ephemeral(self, service: ApplicationService, events: List[Any]): + def enqueue_ephemeral(self, service: ApplicationService, events: List[JsonDict]): self.queued_ephemeral.setdefault(service.id, []).extend(events) self._start_background_request(service) diff --git a/synapse/handlers/appservice.py b/synapse/handlers/appservice.py index 9e88e5e591..674b244ff1 100644 --- a/synapse/handlers/appservice.py +++ b/synapse/handlers/appservice.py @@ -213,7 +213,7 @@ class ApplicationServicesHandler: async def _handle_typing(self, service: ApplicationService, new_token: int): typing_source = self.event_sources.sources["typing"] # Get the typing events from just before current - typing, _key = await typing_source.get_new_events_as( + typing, _ = await typing_source.get_new_events_as( service=service, # For performance reasons, we don't persist the previous # token in the DB and instead fetch the latest typing information @@ -242,7 +242,7 @@ class ApplicationServicesHandler: interested = await service.is_interested_in_presence(user, self.store) if not interested: continue - presence_events, _key = await presence_source.get_new_events( + presence_events, _ = await presence_source.get_new_events( user=user, service=service, from_key=from_key, ) time_now = self.clock.time_msec() diff --git a/synapse/storage/databases/main/appservice.py b/synapse/storage/databases/main/appservice.py index af3b8be943..f7241c65b3 100644 --- a/synapse/storage/databases/main/appservice.py +++ b/synapse/storage/databases/main/appservice.py @@ -187,6 +187,9 @@ class ApplicationServiceTransactionWorkerStore( Args: service: The service who the transaction is for. events: A list of events to put in the transaction. + + Returns: + A new transaction. """ def _create_appservice_txn(txn): |