mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
message send: Introduce dataclass to wrap user-notifications variables.
We will in later commits, extend this class to contain methods to determine if a message is notifiable or not, but for now we only turn it into a dict and pass it on.
This commit is contained in:
committed by
Tim Abbott
parent
2179275020
commit
951b49c048
@@ -110,6 +110,7 @@ from zerver.lib.message import (
|
||||
update_first_visible_message_id,
|
||||
wildcard_mention_allowed,
|
||||
)
|
||||
from zerver.lib.notification_data import UserMessageNotificationsData
|
||||
from zerver.lib.pysa import mark_sanitized
|
||||
from zerver.lib.queue import queue_json_publish
|
||||
from zerver.lib.realm_icon import realm_icon_url
|
||||
@@ -1979,7 +1980,8 @@ def do_send_messages(
|
||||
user_id in send_request.wildcard_mention_user_ids and "wildcard_mentioned" in flags
|
||||
)
|
||||
users.append(
|
||||
dict(
|
||||
asdict(
|
||||
UserMessageNotificationsData(
|
||||
id=user_id,
|
||||
flags=flags,
|
||||
mentioned=("mentioned" in flags),
|
||||
@@ -1990,6 +1992,7 @@ def do_send_messages(
|
||||
sender_is_muted=(user_id in send_request.muted_sender_user_ids),
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if send_request.message.is_stream_message():
|
||||
# Note: This is where authorization for single-stream
|
||||
|
||||
20
zerver/lib/notification_data.py
Normal file
20
zerver/lib/notification_data.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import List
|
||||
|
||||
|
||||
@dataclass
|
||||
class UserMessageNotificationsData:
|
||||
id: int
|
||||
flags: List[str]
|
||||
mentioned: bool
|
||||
online_push_enabled: bool
|
||||
stream_push_notify: bool
|
||||
stream_email_notify: bool
|
||||
wildcard_mention_notify: bool
|
||||
sender_is_muted: bool
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
if self.mentioned:
|
||||
assert "mentioned" in self.flags
|
||||
if self.wildcard_mention_notify:
|
||||
assert "wildcard_mentioned" in self.flags
|
||||
Reference in New Issue
Block a user