From 16174cacf07fa034469edb8108e87db27af7d302 Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Fri, 10 Jun 2022 20:06:59 +0530 Subject: [PATCH] Fix client driver API for UpdateUserCustomStatus (#20433) UpdateUserCustomStatus server API never returned the object. But the client driver tried to parse the JSON response into a struct, which always parsed as an empty struct. We fix that by returning the original response and added a comment to clarify that. Found while adding coverage for custom status in the load-test tool. ```release-note NONE ``` --- model/client4.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/model/client4.go b/model/client4.go index ef28ba7387..fda171b781 100644 --- a/model/client4.go +++ b/model/client4.go @@ -6305,6 +6305,8 @@ func (c *Client4) UpdateUserStatus(userId string, userStatus *Status) (*Status, } // UpdateUserCustomStatus sets a user's custom status based on the provided user id string. +// The returned CustomStatus object is the same as the one passed, and it should be just +// ignored. It's only kept to maintain compatibility. func (c *Client4) UpdateUserCustomStatus(userId string, userCustomStatus *CustomStatus) (*CustomStatus, *Response, error) { buf, err := json.Marshal(userCustomStatus) if err != nil { @@ -6315,11 +6317,10 @@ func (c *Client4) UpdateUserCustomStatus(userId string, userCustomStatus *Custom return nil, BuildResponse(r), err } defer closeBody(r) - var s CustomStatus - if jsonErr := json.NewDecoder(r.Body).Decode(&s); jsonErr != nil { - return nil, nil, NewAppError("UpdateUserCustomStatus", "api.unmarshal_error", nil, jsonErr.Error(), http.StatusInternalServerError) - } - return &s, BuildResponse(r), nil + // This is returning the same status which was passed. + // The API was incorrectly designed to return a status returned from the server, + // but the server doesn't return anything except an OK. + return userCustomStatus, BuildResponse(r), nil } // RemoveUserCustomStatus remove a user's custom status based on the provided user id string.