From 6d8ac7c3c053741ec7c8f660cb76ba1732f0eed8 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Thu, 2 Aug 2018 15:58:10 -0700 Subject: [PATCH] api: Check for BAD_EVENT_QUEUE_ID code. This is the best way to do this check, since it isn't subject to i18n modifying the strings. The server feature was originally introduced in zulip/zulip commit 709c3b50fcba333740bb337bac69a801dbbdc4ee. Since it's only 1 year old and the outcome is quite bad if this check weren't present, we preserve support for older servers. --- zulip/zulip/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/zulip/zulip/__init__.py b/zulip/zulip/__init__.py index 0ffa761..49eb44a 100644 --- a/zulip/zulip/__init__.py +++ b/zulip/zulip/__init__.py @@ -657,7 +657,11 @@ class Client(object): else: if self.verbose: print("Server returned error:\n%s" % res["msg"]) - if res["msg"].startswith("Bad event queue id:"): + # Eventually, we'll only want the + # BAD_EVENT_QUEUE_ID check, but we check for the + # old string to support legacy Zulip servers. We + # should remove that legacy check in 2019. + if res.get("code") == "BAD_EVENT_QUEUE_ID" or res["msg"].startswith("Bad event queue id:"): # Our event queue went away, probably because # we were asleep or the server restarted # abnormally. We may have missed some