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.
This commit is contained in:
Tim Abbott 2018-08-02 15:58:10 -07:00
parent cb183fef4c
commit 6d8ac7c3c0

View file

@ -657,7 +657,11 @@ class Client(object):
else: else:
if self.verbose: if self.verbose:
print("Server returned error:\n%s" % res["msg"]) 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 # Our event queue went away, probably because
# we were asleep or the server restarted # we were asleep or the server restarted
# abnormally. We may have missed some # abnormally. We may have missed some