summary refs log tree commit diff
path: root/synapse/storage/databases/main/search.py
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2020-10-20 17:42:37 +0100
committerAndrew Morgan <andrew@amorgan.xyz>2020-10-20 17:42:37 +0100
commit2bd022e04c6c1a82a73376db8999db0b29ed6cfc (patch)
tree434dede692ea9b7f2474993f386b8801f62ba010 /synapse/storage/databases/main/search.py
parentMerge commit '54f8d73c0' into anoa/dinsic_release_1_21_x (diff)
parentMake _get_e2e_device_keys_and_signatures_txn return an attrs (#8224) (diff)
downloadsynapse-2bd022e04c6c1a82a73376db8999db0b29ed6cfc.tar.xz
Merge commit 'abeab964d' into anoa/dinsic_release_1_21_x
* commit 'abeab964d':
  Make _get_e2e_device_keys_and_signatures_txn return an attrs (#8224)
  Fix errors when updating the user directory with invalid data (#8223)
  Explain better what GDPR-erased means (#8189)
  Convert additional databases to async/await part 3 (#8201)
  Convert appservice code to async/await. (#8207)
  Rename `_get_e2e_device_keys_txn` (#8222)
Diffstat (limited to 'synapse/storage/databases/main/search.py')
-rw-r--r--synapse/storage/databases/main/search.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/synapse/storage/databases/main/search.py b/synapse/storage/databases/main/search.py

index 7f8d1880e5..f01cf2fd02 100644 --- a/synapse/storage/databases/main/search.py +++ b/synapse/storage/databases/main/search.py
@@ -16,9 +16,10 @@ import logging import re from collections import namedtuple -from typing import List, Optional +from typing import List, Optional, Set from synapse.api.errors import SynapseError +from synapse.events import EventBase from synapse.storage._base import SQLBaseStore, db_to_json, make_in_list_sql_clause from synapse.storage.database import DatabasePool from synapse.storage.databases.main.events_worker import EventRedactBehaviour @@ -620,7 +621,9 @@ class SearchStore(SearchBackgroundUpdateStore): "count": count, } - def _find_highlights_in_postgres(self, search_query, events): + async def _find_highlights_in_postgres( + self, search_query: str, events: List[EventBase] + ) -> Set[str]: """Given a list of events and a search term, return a list of words that match from the content of the event. @@ -628,11 +631,11 @@ class SearchStore(SearchBackgroundUpdateStore): highlight the matching parts. Args: - search_query (str) - events (list): A list of events + search_query + events: A list of events Returns: - deferred : A set of strings. + A set of strings. """ def f(txn): @@ -685,7 +688,7 @@ class SearchStore(SearchBackgroundUpdateStore): return highlight_words - return self.db_pool.runInteraction("_find_highlights", f) + return await self.db_pool.runInteraction("_find_highlights", f) def _to_postgres_options(options_dict):