mirror of https://github.com/zulip/zulip.git
message_send: Inline single use of filter_by_exact_message_topic.
Matching the topic exactly, as opposed to case-insensitively, is not a common operation, and one that we want to make difficult to do accidentally. Inline the single use case of it.
This commit is contained in:
parent
710524465a
commit
9d3d57e786
|
@ -69,7 +69,7 @@ from zerver.lib.stream_topic import StreamTopicTarget
|
|||
from zerver.lib.streams import access_stream_for_send_message, ensure_stream
|
||||
from zerver.lib.string_validation import check_stream_name
|
||||
from zerver.lib.timestamp import timestamp_to_datetime
|
||||
from zerver.lib.topic import filter_by_exact_message_topic, participants_for_topic
|
||||
from zerver.lib.topic import participants_for_topic
|
||||
from zerver.lib.url_preview.types import UrlEmbedData
|
||||
from zerver.lib.user_message import UserMessageLite, bulk_insert_ums
|
||||
from zerver.lib.validator import check_widget_content
|
||||
|
@ -1084,20 +1084,16 @@ def already_sent_mirrored_message_id(message: Message) -> Optional[int]:
|
|||
else:
|
||||
time_window = datetime.timedelta(seconds=0)
|
||||
|
||||
query = Message.objects.filter(
|
||||
messages = Message.objects.filter(
|
||||
sender=message.sender,
|
||||
recipient=message.recipient,
|
||||
subject=message.topic_name(),
|
||||
content=message.content,
|
||||
sending_client=message.sending_client,
|
||||
date_sent__gte=message.date_sent - time_window,
|
||||
date_sent__lte=message.date_sent + time_window,
|
||||
)
|
||||
|
||||
messages = filter_by_exact_message_topic(
|
||||
query=query,
|
||||
message=message,
|
||||
)
|
||||
|
||||
if messages.exists():
|
||||
return messages[0].id
|
||||
return None
|
||||
|
|
|
@ -86,11 +86,6 @@ def topic_column_sa() -> ColumnElement[Text]:
|
|||
return column("subject", Text)
|
||||
|
||||
|
||||
def filter_by_exact_message_topic(query: QuerySet[Message], message: Message) -> QuerySet[Message]:
|
||||
topic_name = message.topic_name()
|
||||
return query.filter(subject=topic_name)
|
||||
|
||||
|
||||
def filter_by_topic_name_via_message(
|
||||
query: QuerySet[UserMessage], topic_name: str
|
||||
) -> QuerySet[UserMessage]:
|
||||
|
|
Loading…
Reference in New Issue