zilencer: Eliminate submit_feedback indirection.

This commit is contained in:
Tim Abbott 2017-03-05 23:40:34 -08:00
parent ed5b76f566
commit e1c1f96f9e
5 changed files with 8 additions and 12 deletions

View File

@ -1,6 +1,7 @@
from __future__ import absolute_import
from typing import Any, Dict, Optional, Text
from django.conf import settings
from typing import Any, Mapping, Optional, Text
from zerver.lib.actions import internal_send_message
from zerver.lib.redis_utils import get_redis_client
@ -44,7 +45,7 @@ def get_ticket_number():
return ticket_number
def deliver_feedback_by_zulip(message):
# type: (Dict[str, Any]) -> None
# type: (Mapping[str, Any]) -> None
subject = "%s" % (message["sender_email"],)
if len(subject) > 60:
@ -72,4 +73,4 @@ def deliver_feedback_by_zulip(message):
content += message['content']
internal_send_message(realm_for_email("feedback@zulip.com"), "feedback@zulip.com",
"stream", "support", subject, content)
"stream", settings.FEEDBACK_STREAM, subject, content)

View File

@ -10,6 +10,7 @@ from zerver.models import get_user_profile_by_email, \
UserMessage, Message, Realm
from zerver.lib.context_managers import lockfile
from zerver.lib.error_notify import do_report_error
from zerver.lib.feedback import deliver_feedback_by_zulip
from zerver.lib.queue import SimpleQueueClient, queue_json_publish
from zerver.lib.timestamp import timestamp_to_datetime
from zerver.lib.notifications import handle_missedmessage_emails, enqueue_welcome_emails, \
@ -251,6 +252,8 @@ class FeedbackBot(QueueProcessingWorker):
headers = {'Reply-To': '"%s" <%s>' % (event["sender_full_name"], event["sender_email"])}
msg = EmailMessage(subject, content, from_email, [to_email], headers=headers)
msg.send()
if settings.FEEDBACK_STREAM is not None:
deliver_feedback_by_zulip(event)
@assign_queue('error_reports')
class ErrorReporter(QueueProcessingWorker):

View File

@ -10,8 +10,6 @@ i18n_urlpatterns = [] # type: Any
# Zilencer views following the REST API style
v1_api_and_json_patterns = [
url('^deployment/feedback$', rest_dispatch,
{'POST': 'zilencer.views.submit_feedback'}),
url('^deployment/report_error$', rest_dispatch,
{'POST': 'zerver.views.report.report_error'}),
]

View File

@ -7,17 +7,10 @@ from zilencer.models import Deployment
from zerver.decorator import has_request_variables, REQ
from zerver.lib.error_notify import do_report_error
from zerver.lib.feedback import deliver_feedback_by_zulip
from zerver.lib.validator import check_dict
from typing import Any, Dict, Text
@has_request_variables
def submit_feedback(request, deployment, message=REQ(validator=check_dict([]))):
# type: (HttpRequest, Deployment, Dict[str, Text]) -> HttpResponse
deliver_feedback_by_zulip(message)
return HttpResponse(message['sender_email'])
@has_request_variables
def report_error(request, deployment, type=REQ(), report=REQ(validator=check_dict([]))):
# type: (HttpRequest, Deployment, Text, Dict[str, Any]) -> HttpResponse

View File

@ -151,6 +151,7 @@ DEFAULT_SETTINGS = {'TWITTER_CONSUMER_KEY': '',
'SEND_MISSED_MESSAGE_EMAILS_AS_USER': False,
'SERVER_EMAIL': None,
'FEEDBACK_EMAIL': None,
'FEEDBACK_STREAM': None,
'WELCOME_EMAIL_SENDER': None,
'EMAIL_DELIVERER_DISABLED': False,
'ENABLE_GRAVATAR': True,