From 0d93ec6214e5a8b4837674adda17db4ad8005cc4 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Sun, 26 Jun 2022 20:47:45 -0700 Subject: [PATCH] tornado: Remove dead check for message format. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was for the old /messages/latest API that was removed in commit e06722657a74aa850f667dc0e889a5364ff691c6. 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 --- zerver/tornado/event_queue.py | 1 - zerver/tornado/handlers.py | 14 ++------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/zerver/tornado/event_queue.py b/zerver/tornado/event_queue.py index 55db687956..138ee6240b 100644 --- a/zerver/tornado/event_queue.py +++ b/zerver/tornado/event_queue.py @@ -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( diff --git a/zerver/tornado/handlers.py b/zerver/tornado/handlers.py index ce175f4a37..194b912794 100644 --- a/zerver/tornado/handlers.py +++ b/zerver/tornado/handlers.py @@ -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)