mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
types: Better types for API fields.
Signed-off-by: Zixuan James Li <359101898@qq.com>
This commit is contained in:
committed by
Tim Abbott
parent
e6e975b470
commit
44ecd66eae
@@ -221,6 +221,49 @@ class NeverSubscribedStreamDict(TypedDict):
|
||||
subscribers: NotRequired[List[int]]
|
||||
|
||||
|
||||
class APIStreamDict(TypedDict):
|
||||
"""Stream information provided to Zulip clients as a dictionary via API.
|
||||
It should contain all the fields specified in `zerver.models.Stream.API_FIELDS`
|
||||
with few exceptions and possible additional fields.
|
||||
"""
|
||||
|
||||
date_created: int
|
||||
description: str
|
||||
first_message_id: Optional[int]
|
||||
history_public_to_subscribers: bool
|
||||
invite_only: bool
|
||||
is_web_public: bool
|
||||
message_retention_days: Optional[int]
|
||||
name: str
|
||||
rendered_description: str
|
||||
stream_id: int # `stream_id`` represents `id` of the `Stream` object in `API_FIELDS`
|
||||
stream_post_policy: int
|
||||
# Computed fields not specified in `Stream.API_FIELDS`
|
||||
is_announcement_only: bool
|
||||
is_default: NotRequired[bool]
|
||||
|
||||
|
||||
class APISubscriptionDict(APIStreamDict):
|
||||
"""Similar to StreamClientDict, it should contain all the fields specified in
|
||||
`zerver.models.Subscription.API_FIELDS` and several additional fields.
|
||||
"""
|
||||
|
||||
audible_notifications: Optional[bool]
|
||||
color: str
|
||||
desktop_notifications: Optional[bool]
|
||||
email_notifications: Optional[bool]
|
||||
is_muted: bool
|
||||
pin_to_top: bool
|
||||
push_notifications: Optional[bool]
|
||||
role: int
|
||||
wildcard_mentions_notify: Optional[bool]
|
||||
# Computed fields not specified in `Subscription.API_FIELDS`
|
||||
email_address: str
|
||||
in_home_view: bool
|
||||
stream_weekly_traffic: Optional[int]
|
||||
subscribers: List[int]
|
||||
|
||||
|
||||
@dataclass
|
||||
class SubscriptionInfo:
|
||||
subscriptions: List[SubscriptionStreamDict]
|
||||
|
||||
Reference in New Issue
Block a user