tornado: Remove dead check for message format.

This was for the old /messages/latest API that was removed in commit
e06722657a.

If we wanted a new check like this, it shouldn’t go in zulip_finish,
because that only runs when the client gets an asynchronous response
from polling an initially-empty queue, and not when the client gets a
synchronous response from polling a nonempty queue.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2022-06-26 20:47:45 -07:00 committed by Tim Abbott
parent 4fd51cb5ad
commit 0d93ec6214
2 changed files with 2 additions and 13 deletions

View File

@ -195,7 +195,6 @@ class ClientDescriptor:
self.current_handler_id,
self.event_queue.id,
self.event_queue.contents(),
self.apply_markdown,
)
except Exception:
logging.exception(

View File

@ -40,9 +40,7 @@ def handler_stats_string() -> str:
return f"{len(handlers)} handlers, latest ID {current_handler_id}"
def finish_handler(
handler_id: int, event_queue_id: str, contents: List[Dict[str, Any]], apply_markdown: bool
) -> None:
def finish_handler(handler_id: int, event_queue_id: str, contents: List[Dict[str, Any]]) -> None:
try:
# We do the import during runtime to avoid cyclic dependency
# with zerver.lib.request
@ -67,7 +65,6 @@ def finish_handler(
handler.zulip_finish,
dict(result="success", msg="", events=contents, queue_id=event_queue_id),
request,
apply_markdown=apply_markdown,
)
except Exception as e:
if not (
@ -206,18 +203,11 @@ class AsyncDjangoHandler(tornado.web.RequestHandler, base.BaseHandler):
if client_descriptor is not None:
client_descriptor.disconnect_handler(client_closed=True)
async def zulip_finish(
self, result_dict: Dict[str, Any], old_request: HttpRequest, apply_markdown: bool
) -> None:
async def zulip_finish(self, result_dict: Dict[str, Any], old_request: HttpRequest) -> None:
# Function called when we want to break a long-polled
# get_events request and return a response to the client.
# Marshall the response data from result_dict.
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)
await self.finish("Internal error: bad message format")
if result_dict["result"] == "error":
self.set_status(400)