message: Use .is_channel_message column instead of is_stream_message().

This avoids a potential unnecessary message.recipient fetch required by
is_stream_message(). is_stream_message() methods precedes the addition
of the denormalized is_channel_message column and is now unnecessary.

In practice, we usually fetch Message objects with `.recipient` already,
so I don't expect any notable performance impact here - but it's still a
useful change to make.

(cherry picked from commit 51cef01c29)
This commit is contained in:
Mateusz Mandera
2025-08-17 03:25:23 +08:00
committed by Tim Abbott
parent 51711bd3d9
commit 8c9c39059d
18 changed files with 41 additions and 44 deletions

View File

@@ -1058,7 +1058,7 @@ def get_apns_alert_title(message: Message, language: str) -> str:
assert isinstance(recipients, list)
if len(recipients) > 2:
return ", ".join(sorted(r["full_name"] for r in recipients))
elif message.is_stream_message():
elif message.is_channel_message:
stream_name = get_message_stream_name_from_database(message)
topic_display_name = get_topic_display_name(message.topic_name(), language)
return f"#{stream_name} > {topic_display_name}"
@@ -1718,7 +1718,7 @@ def handle_push_notification(user_profile_id: int, missed_message: dict[str, Any
user_profile, {trigger}, mentioned_user_group_members_count
)
if message.is_stream_message():
if message.is_channel_message:
# This will almost always be True. The corner case where you
# can be receiving a message from a user you cannot access
# involves your being a guest user whose access is restricted