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
```
Этот коммит содержится в:
Agniva De Sarker
2022-06-10 20:06:59 +05:30
коммит произвёл GitHub
родитель 35d473b3a0
Коммит 16174cacf0

Просмотреть файл

@@ -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. // 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) { func (c *Client4) UpdateUserCustomStatus(userId string, userCustomStatus *CustomStatus) (*CustomStatus, *Response, error) {
buf, err := json.Marshal(userCustomStatus) buf, err := json.Marshal(userCustomStatus)
if err != nil { if err != nil {
@@ -6315,11 +6317,10 @@ func (c *Client4) UpdateUserCustomStatus(userId string, userCustomStatus *Custom
return nil, BuildResponse(r), err return nil, BuildResponse(r), err
} }
defer closeBody(r) defer closeBody(r)
var s CustomStatus // This is returning the same status which was passed.
if jsonErr := json.NewDecoder(r.Body).Decode(&s); jsonErr != nil { // The API was incorrectly designed to return a status returned from the server,
return nil, nil, NewAppError("UpdateUserCustomStatus", "api.unmarshal_error", nil, jsonErr.Error(), http.StatusInternalServerError) // but the server doesn't return anything except an OK.
} return userCustomStatus, BuildResponse(r), nil
return &s, BuildResponse(r), nil
} }
// RemoveUserCustomStatus remove a user's custom status based on the provided user id string. // RemoveUserCustomStatus remove a user's custom status based on the provided user id string.