Skip to content

Commit c59b143

Browse files
PIG208timabbott
authored andcommitted
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.
1 parent c6b6a82 commit c59b143

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

zulip/zulip/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,8 +1308,11 @@ def update_user_by_id(self, user_id: int, **request: Any) -> Dict[str, Any]:
13081308
{'result': 'success', 'msg': ''}
13091309
"""
13101310

1311-
for key, value in request.items():
1312-
request[key] = json.dumps(value)
1311+
if "full_name" in request and self.feature_level < 106:
1312+
# As noted in https://github.com/zulip/zulip/issues/18409,
1313+
# before feature level 106, the server expected a
1314+
# buggy double JSON encoding of the `full_name` parameter.
1315+
request["full_name"] = json.dumps(request["full_name"])
13131316

13141317
return self.call_endpoint(url=f"users/{user_id}", method="PATCH", request=request)
13151318

0 commit comments

Comments
 (0)