mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 04:53:36 +00:00
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.
This commit is contained in:
committed by
Tim Abbott
parent
4e3ec77a0f
commit
51cef01c29
@@ -283,16 +283,6 @@ class Message(AbstractMessage):
|
||||
def set_topic_name(self, topic_name: str) -> None:
|
||||
self.subject = topic_name
|
||||
|
||||
def is_stream_message(self) -> bool:
|
||||
"""
|
||||
Find out whether a message is a stream message by
|
||||
looking up its recipient.type. TODO: Make this
|
||||
an easier operation by denormalizing the message
|
||||
type onto Message, either explicitly (message.type)
|
||||
or implicitly (message.stream_id is not None).
|
||||
"""
|
||||
return self.recipient.type == Recipient.STREAM
|
||||
|
||||
def get_realm(self) -> Realm:
|
||||
return self.realm
|
||||
|
||||
|
||||
@@ -225,7 +225,7 @@ class ScheduledMessage(models.Model):
|
||||
def set_topic_name(self, topic_name: str) -> None:
|
||||
self.subject = topic_name
|
||||
|
||||
def is_stream_message(self) -> bool:
|
||||
def is_channel_message(self) -> bool:
|
||||
return self.recipient.type == Recipient.STREAM
|
||||
|
||||
def to_dict(self) -> APIScheduledStreamMessageDict | APIScheduledDirectMessageDict:
|
||||
|
||||
Reference in New Issue
Block a user