1515# limitations under the License.
1616
1717import logging
18- from typing import List
18+ from typing import Dict , List , Union
1919
2020from synapse .metrics .background_process_metrics import run_as_background_process
2121from synapse .storage ._base import LoggingTransaction , SQLBaseStore , db_to_json
@@ -383,19 +383,20 @@ def get_no_receipt(txn):
383383 # Now return the first `limit`
384384 return notifs [:limit ]
385385
386- def get_if_maybe_push_in_range_for_user (self , user_id , min_stream_ordering ):
386+ async def get_if_maybe_push_in_range_for_user (
387+ self , user_id : str , min_stream_ordering : int
388+ ) -> bool :
387389 """A fast check to see if there might be something to push for the
388390 user since the given stream ordering. May return false positives.
389391
390392 Useful to know whether to bother starting a pusher on start up or not.
391393
392394 Args:
393- user_id (str)
394- min_stream_ordering (int)
395+ user_id
396+ min_stream_ordering
395397
396398 Returns:
397- Deferred[bool]: True if there may be push to process, False if
398- there definitely isn't.
399+ True if there may be push to process, False if there definitely isn't.
399400 """
400401
401402 def _get_if_maybe_push_in_range_for_user_txn (txn ):
@@ -408,22 +409,20 @@ def _get_if_maybe_push_in_range_for_user_txn(txn):
408409 txn .execute (sql , (user_id , min_stream_ordering ))
409410 return bool (txn .fetchone ())
410411
411- return self .db_pool .runInteraction (
412+ return await self .db_pool .runInteraction (
412413 "get_if_maybe_push_in_range_for_user" ,
413414 _get_if_maybe_push_in_range_for_user_txn ,
414415 )
415416
416- async def add_push_actions_to_staging (self , event_id , user_id_actions ):
417+ async def add_push_actions_to_staging (
418+ self , event_id : str , user_id_actions : Dict [str , List [Union [dict , str ]]]
419+ ) -> None :
417420 """Add the push actions for the event to the push action staging area.
418421
419422 Args:
420- event_id (str)
421- user_id_actions (dict[str, list[dict|str])]): A dictionary mapping
422- user_id to list of push actions, where an action can either be
423- a string or dict.
424-
425- Returns:
426- Deferred
423+ event_id
424+ user_id_actions: A mapping of user_id to list of push actions, where
425+ an action can either be a string or dict.
427426 """
428427
429428 if not user_id_actions :
@@ -507,7 +506,7 @@ def _find_stream_orderings_for_times_txn(self, txn):
507506 "Found stream ordering 1 day ago: it's %d" , self .stream_ordering_day_ago
508507 )
509508
510- def find_first_stream_ordering_after_ts (self , ts ) :
509+ async def find_first_stream_ordering_after_ts (self , ts : int ) -> int :
511510 """Gets the stream ordering corresponding to a given timestamp.
512511
513512 Specifically, finds the stream_ordering of the first event that was
@@ -516,13 +515,12 @@ def find_first_stream_ordering_after_ts(self, ts):
516515 relatively slow.
517516
518517 Args:
519- ts (int) : timestamp in millis
518+ ts: timestamp in millis
520519
521520 Returns:
522- Deferred[int]: stream ordering of the first event received on/after
523- the timestamp
521+ stream ordering of the first event received on/after the timestamp
524522 """
525- return self .db_pool .runInteraction (
523+ return await self .db_pool .runInteraction (
526524 "_find_first_stream_ordering_after_ts_txn" ,
527525 self ._find_first_stream_ordering_after_ts_txn ,
528526 ts ,
0 commit comments