Skip to content

Commit

Permalink
handlers: Rename confusingly named response to result_dict.
Browse files Browse the repository at this point in the history
This should somewhat increase the readability of zulip_finish.
  • Loading branch information
timabbott committed Feb 8, 2020
1 parent 4572be8 commit fc58ae1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions zerver/tornado/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,28 +324,28 @@ def apply_response_middleware(self, request: HttpRequest, response: HttpResponse
return response

class AsyncDjangoHandler(AsyncDjangoHandlerBase):
def zulip_finish(self, response: Dict[str, Any], request: HttpRequest,
def zulip_finish(self, result_dict: Dict[str, Any], request: HttpRequest,
apply_markdown: bool) -> None:
# Make sure that Markdown rendering really happened, if requested.
# This is a security issue because it's where we escape HTML.
# c.f. ticket #64
#
# apply_markdown=True is the fail-safe default.
if response['result'] == 'success' and 'messages' in response and apply_markdown:
for msg in response['messages']:
if result_dict['result'] == 'success' and 'messages' in result_dict and apply_markdown:
for msg in result_dict['messages']:
if msg['content_type'] != 'text/html':
self.set_status(500)
self.finish('Internal error: bad message format')
if response['result'] == 'error':
if result_dict['result'] == 'error':
self.set_status(400)

# Call the Django response middleware on our object so that
# e.g. our own logging code can run; but don't actually use
# the headers from that since sending those to Tornado seems
# tricky; instead just send the (already json-rendered)
# content on to Tornado
django_response = json_response(res_type=response['result'],
data=response, status=self.get_status())
django_response = json_response(res_type=result_dict['result'],
data=result_dict, status=self.get_status())
django_response = self.apply_response_middleware(request, django_response,
request._resolver)
# Pass through the content-type from Django, as json content should be
Expand Down

0 comments on commit fc58ae1

Please sign in to comment.