mirror of https://github.com/zulip/zulip.git
Extract get_turtle_message().
This seems like kind of a silly function to extract to topic.py, but it will theoretically help us sweep "subject" if we change the DB. It had test coverage.
This commit is contained in:
parent
cc33e4cd0c
commit
eb4d279bbc
|
@ -40,7 +40,6 @@ FILES_WITH_LEGACY_SUBJECT = {
|
||||||
# TRY TO FIX THESE! If you can't fix them, try to
|
# TRY TO FIX THESE! If you can't fix them, try to
|
||||||
# add comments here and/or in the file itself about
|
# add comments here and/or in the file itself about
|
||||||
# why sweeping subject is tricky.
|
# why sweeping subject is tricky.
|
||||||
'zerver/lib/onboarding.py',
|
|
||||||
'zerver/lib/stream_topic.py',
|
'zerver/lib/stream_topic.py',
|
||||||
|
|
||||||
# This has lots of query data embedded, so it's hard
|
# This has lots of query data embedded, so it's hard
|
||||||
|
|
|
@ -5,6 +5,7 @@ from zerver.lib.actions import set_default_streams, bulk_add_subscriptions, \
|
||||||
internal_prep_stream_message, internal_send_private_message, \
|
internal_prep_stream_message, internal_send_private_message, \
|
||||||
create_stream_if_needed, create_streams_if_needed, do_send_messages, \
|
create_stream_if_needed, create_streams_if_needed, do_send_messages, \
|
||||||
do_add_reaction_legacy, create_users, missing_any_realm_internal_bots
|
do_add_reaction_legacy, create_users, missing_any_realm_internal_bots
|
||||||
|
from zerver.lib.topic import get_turtle_message
|
||||||
from zerver.models import Realm, UserProfile, Message, Reaction, get_system_bot
|
from zerver.models import Realm, UserProfile, Message, Reaction, get_system_bot
|
||||||
|
|
||||||
from typing import Any, Dict, List, Mapping
|
from typing import Any, Dict, List, Mapping
|
||||||
|
@ -114,8 +115,5 @@ def send_initial_realm_messages(realm: Realm) -> None:
|
||||||
# We find the one of our just-sent messages with turtle.png in it,
|
# We find the one of our just-sent messages with turtle.png in it,
|
||||||
# and react to it. This is a bit hacky, but works and is kinda a
|
# and react to it. This is a bit hacky, but works and is kinda a
|
||||||
# 1-off thing.
|
# 1-off thing.
|
||||||
turtle_message = Message.objects.get(
|
turtle_message = get_turtle_message(message_ids=message_ids)
|
||||||
id__in=message_ids,
|
|
||||||
subject='topic demonstration',
|
|
||||||
content__icontains='cute/turtle.png')
|
|
||||||
do_add_reaction_legacy(welcome_bot, turtle_message, 'turtle')
|
do_add_reaction_legacy(welcome_bot, turtle_message, 'turtle')
|
||||||
|
|
|
@ -227,3 +227,12 @@ def get_topic_history_for_web_public_stream(recipient: Recipient) -> List[Dict[s
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
return generate_topic_history_from_db_rows(rows)
|
return generate_topic_history_from_db_rows(rows)
|
||||||
|
|
||||||
|
def get_turtle_message(message_ids: List[int]) -> Message:
|
||||||
|
# This is used for onboarding, and it's only extracted
|
||||||
|
# here to make subject -> topic sweeping easier.
|
||||||
|
turtle_message = Message.objects.get( # nolint
|
||||||
|
id__in=message_ids,
|
||||||
|
subject='topic demonstration',
|
||||||
|
content__icontains='cute/turtle.png')
|
||||||
|
return turtle_message
|
||||||
|
|
Loading…
Reference in New Issue