mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 08:26:11 +00:00
onboarding: Add turtle reaction to an initial message.
This commit is contained in:
@@ -263,7 +263,9 @@ def build_custom_checkers(by_lang):
|
||||
'''},
|
||||
# Directly fetching Message objects in e.g. views code is often a security bug.
|
||||
{'pattern': '[^r][M]essage.objects.get',
|
||||
'exclude': set(["zerver/tests", "zerver/worker/queue_processors.py"]),
|
||||
'exclude': set(["zerver/tests",
|
||||
"zerver/lib/onboarding.py",
|
||||
"zerver/worker/queue_processors.py"]),
|
||||
'description': 'Please use access_message() to fetch Message objects',
|
||||
},
|
||||
{'pattern': '[S]tream.objects.get',
|
||||
|
||||
@@ -5,8 +5,9 @@ from django.conf import settings
|
||||
|
||||
from zerver.lib.actions import set_default_streams, bulk_add_subscriptions, \
|
||||
internal_prep_stream_message, internal_send_private_message, \
|
||||
create_stream_if_needed, create_streams_if_needed, do_send_messages
|
||||
from zerver.models import Realm, UserProfile, Reaction, get_system_bot
|
||||
create_stream_if_needed, create_streams_if_needed, do_send_messages, \
|
||||
do_add_reaction
|
||||
from zerver.models import Realm, UserProfile, Message, Reaction, get_system_bot
|
||||
|
||||
from typing import Any, Dict, List, Mapping, Text
|
||||
|
||||
@@ -47,6 +48,7 @@ def setup_initial_private_stream(user):
|
||||
|
||||
def send_initial_realm_messages(realm):
|
||||
# type: (Realm) -> None
|
||||
welcome_bot = get_system_bot(settings.WELCOME_BOT)
|
||||
# Make sure each stream created in the realm creation process has at least one message below
|
||||
# Order corresponds to the ordering of the streams on the left sidebar, to make the initial Home
|
||||
# view slightly less overwhelming
|
||||
@@ -81,6 +83,15 @@ def send_initial_realm_messages(realm):
|
||||
"or two words will do it!"},
|
||||
] # type: List[Dict[str, Text]]
|
||||
messages = [internal_prep_stream_message(
|
||||
realm, get_system_bot(settings.WELCOME_BOT),
|
||||
realm, welcome_bot,
|
||||
message['stream'], message['topic'], message['content']) for message in welcome_messages]
|
||||
do_send_messages(messages)
|
||||
message_ids = do_send_messages(messages)
|
||||
|
||||
# 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
|
||||
# 1-off thing.
|
||||
turtle_message = Message.objects.get(
|
||||
id__in=message_ids,
|
||||
subject='topic demonstration',
|
||||
content__icontains='cute/turtle.png')
|
||||
do_add_reaction(welcome_bot, turtle_message, 'turtle')
|
||||
|
||||
Reference in New Issue
Block a user