api: Make update_user_by_id compatible.

As part of supporting the change in zulip/zulip#18409, we add a
conditional to send the old/buggy format only to servers with feature
levels indicating they don't support the modern version.
This commit is contained in:
PIG208 2021-08-02 23:41:55 +08:00 committed by Tim Abbott
parent c6b6a82d90
commit c59b143d96

View file

@ -1308,8 +1308,11 @@ class Client:
{'result': 'success', 'msg': ''} {'result': 'success', 'msg': ''}
""" """
for key, value in request.items(): if "full_name" in request and self.feature_level < 106:
request[key] = json.dumps(value) # As noted in https://github.com/zulip/zulip/issues/18409,
# before feature level 106, the server expected a
# buggy double JSON encoding of the `full_name` parameter.
request["full_name"] = json.dumps(request["full_name"])
return self.call_endpoint(url=f"users/{user_id}", method="PATCH", request=request) return self.call_endpoint(url=f"users/{user_id}", method="PATCH", request=request)