From aeb2ad5f460dea9737fd268db630e926a434211f Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Bodas Date: Mon, 21 Jun 2021 18:55:47 +0530 Subject: [PATCH] notification_data: Annotate `flags` with `Collection`. Since `flags` here could be iterated through multiple times (to check for push/email notifiability), we use `Collection`. Inspired by 871e73ab8f2831a8e6f2d63b630c6f6bb71a06bb. The other change here in the `event_queue` code is prep for using the `UserMessageNotificationsData` class there. --- zerver/lib/notification_data.py | 4 ++-- zerver/tornado/event_queue.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/zerver/lib/notification_data.py b/zerver/lib/notification_data.py index 6ec0e6b550..db59f6de4e 100644 --- a/zerver/lib/notification_data.py +++ b/zerver/lib/notification_data.py @@ -1,11 +1,11 @@ from dataclasses import dataclass -from typing import List +from typing import Collection @dataclass class UserMessageNotificationsData: id: int - flags: List[str] + flags: Collection[str] mentioned: bool online_push_enabled: bool stream_push_notify: bool diff --git a/zerver/tornado/event_queue.py b/zerver/tornado/event_queue.py index 8f02e4b42b..a65d25048c 100644 --- a/zerver/tornado/event_queue.py +++ b/zerver/tornado/event_queue.py @@ -948,7 +948,7 @@ def process_message_event( for user_data in users: user_profile_id: int = user_data["id"] - flags: Iterable[str] = user_data.get("flags", []) + flags: Collection[str] = user_data.get("flags", []) # If the recipient was offline and the message was a single or group PM to them # or they were @-notified potentially notify more immediately