mirror of https://github.com/zulip/zulip.git
Extract filter_by_exact_message_topic().
This commit is contained in:
parent
56ecd227ff
commit
dc8f893494
|
@ -55,6 +55,9 @@ from zerver.lib.stream_subscription import (
|
|||
num_subscribers_for_stream_id,
|
||||
)
|
||||
from zerver.lib.stream_topic import StreamTopicTarget
|
||||
from zerver.lib.topic import (
|
||||
filter_by_exact_message_topic,
|
||||
)
|
||||
from zerver.lib.topic_mutes import (
|
||||
get_topic_mutes,
|
||||
add_topic_mute,
|
||||
|
@ -1784,15 +1787,19 @@ def already_sent_mirrored_message_id(message: Message) -> Optional[int]:
|
|||
else:
|
||||
time_window = datetime.timedelta(seconds=0)
|
||||
|
||||
messages = Message.objects.filter(
|
||||
query = Message.objects.filter(
|
||||
sender=message.sender,
|
||||
recipient=message.recipient,
|
||||
content=message.content,
|
||||
subject=message.subject,
|
||||
sending_client=message.sending_client,
|
||||
pub_date__gte=message.pub_date - time_window,
|
||||
pub_date__lte=message.pub_date + time_window)
|
||||
|
||||
messages = filter_by_exact_message_topic(
|
||||
query=query,
|
||||
message=message,
|
||||
)
|
||||
|
||||
if messages.exists():
|
||||
return messages[0].id
|
||||
return None
|
||||
|
|
|
@ -1,9 +1,18 @@
|
|||
from django.db import connection
|
||||
from django.db.models.query import QuerySet
|
||||
|
||||
from zerver.models import UserProfile, Recipient
|
||||
from zerver.models import (
|
||||
Message,
|
||||
Recipient,
|
||||
UserProfile,
|
||||
)
|
||||
|
||||
from typing import Any, Dict, List, Tuple
|
||||
|
||||
def filter_by_exact_message_topic(query: QuerySet, message: Message) -> QuerySet:
|
||||
topic_name = message.topic_name()
|
||||
return query.filter(subject=topic_name)
|
||||
|
||||
def generate_topic_history_from_db_rows(rows: List[Tuple[str, int]]) -> List[Dict[str, Any]]:
|
||||
canonical_topic_names = {} # type: Dict[str, Tuple[int, str]]
|
||||
|
||||
|
|
Loading…
Reference in New Issue