mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-13 06:42:20 -04:00
Improved push typing (#11409)
Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
This commit is contained in:
parent
35b1900f00
commit
a9481223d1
7 changed files with 210 additions and 36 deletions
|
@ -16,6 +16,7 @@ import logging
|
|||
from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union
|
||||
|
||||
import attr
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
from synapse.metrics.background_process_metrics import wrap_as_background_process
|
||||
from synapse.storage._base import SQLBaseStore, db_to_json
|
||||
|
@ -37,6 +38,20 @@ DEFAULT_HIGHLIGHT_ACTION = [
|
|||
]
|
||||
|
||||
|
||||
class BasePushAction(TypedDict):
|
||||
event_id: str
|
||||
actions: List[Union[dict, str]]
|
||||
|
||||
|
||||
class HttpPushAction(BasePushAction):
|
||||
room_id: str
|
||||
stream_ordering: int
|
||||
|
||||
|
||||
class EmailPushAction(HttpPushAction):
|
||||
received_ts: Optional[int]
|
||||
|
||||
|
||||
def _serialize_action(actions, is_highlight):
|
||||
"""Custom serializer for actions. This allows us to "compress" common actions.
|
||||
|
||||
|
@ -221,7 +236,7 @@ class EventPushActionsWorkerStore(SQLBaseStore):
|
|||
min_stream_ordering: int,
|
||||
max_stream_ordering: int,
|
||||
limit: int = 20,
|
||||
) -> List[dict]:
|
||||
) -> List[HttpPushAction]:
|
||||
"""Get a list of the most recent unread push actions for a given user,
|
||||
within the given stream ordering range. Called by the httppusher.
|
||||
|
||||
|
@ -326,7 +341,7 @@ class EventPushActionsWorkerStore(SQLBaseStore):
|
|||
min_stream_ordering: int,
|
||||
max_stream_ordering: int,
|
||||
limit: int = 20,
|
||||
) -> List[dict]:
|
||||
) -> List[EmailPushAction]:
|
||||
"""Get a list of the most recent unread push actions for a given user,
|
||||
within the given stream ordering range. Called by the emailpusher
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue