diff --git a/zerver/views/__init__.py b/zerver/views/__init__.py index 4159b7220c..31ea162ed0 100644 --- a/zerver/views/__init__.py +++ b/zerver/views/__init__.py @@ -1001,6 +1001,25 @@ def json_change_enter_sends(request, user_profile, do_change_enter_sends(user_profile, enter_sends) return json_success() + +@authenticated_json_post_view +@has_request_variables +def json_tutorial_send_message(request, user_profile, type=REQ, + recipient=REQ, topic=REQ, content=REQ): + """ + This function, used by the onboarding tutorial, causes the Tutorial Bot to + send you the message you pass in here. (That way, the Tutorial Bot's + messages to you get rendered by the server and therefore look like any other + message.) + """ + sender_name = "welcome-bot@zulip.com" + if type == 'stream': + internal_send_message(sender_name, "stream", recipient, topic, content, + realm=user_profile.realm) + return json_success() + # For now, there are no PM cases. + return json_error('Bad data passed in to tutorial_send_message') + @authenticated_json_post_view @has_request_variables def json_tutorial_status(request, user_profile, status=REQ('status')): diff --git a/zproject/settings.py b/zproject/settings.py index c0247fbc31..9238084391 100644 --- a/zproject/settings.py +++ b/zproject/settings.py @@ -336,7 +336,10 @@ INTERNAL_BOTS = [ {'var_name': 'NOTIFICATION_BOT', 'name': 'Nagios Send Bot'}, {'var_name': 'NAGIOS_RECEIVE_BOT', 'email_template': 'nagios-receive-bot@%s', - 'name': 'Nagios Receive Bot'} ] + 'name': 'Nagios Receive Bot'}, + {'var_name': 'WELCOME_BOT', + 'email_template': 'welcome-bot@%s', + 'name': 'Welcome Bot'} ] INTERNAL_BOT_DOMAIN = "zulip.com" diff --git a/zproject/urls.py b/zproject/urls.py index 404849cd82..7e6694a3e4 100644 --- a/zproject/urls.py +++ b/zproject/urls.py @@ -123,6 +123,7 @@ urlpatterns += patterns('zerver.views', url(r'^json/fetch_api_key$', 'json_fetch_api_key'), url(r'^json/update_active_status$', 'json_update_active_status'), url(r'^json/get_active_statuses$', 'json_get_active_statuses'), + url(r'^json/tutorial_send_message$', 'json_tutorial_send_message'), url(r'^json/tutorial_status$', 'json_tutorial_status'), url(r'^json/change_enter_sends$', 'json_change_enter_sends'), url(r'^json/get_profile$', 'json_get_profile'),