[MM-27367] fix ldap group decoding in client (#15192)

Summary

    The data returned by the get ldap groups api endpoint was being decoded incorrectly in the Go client.

Ticket Link

    https://mattermost.atlassian.net/browse/MM-27367
This commit is contained in:
Ashish Bhate
2020-08-19 10:32:53 +00:00
committed by GitHub
parent e33ab02e1a
commit 94e50c30e3

View File

@@ -3875,7 +3875,19 @@ func (c *Client4) GetLdapGroups() ([]*Group, *Response) {
}
defer closeBody(r)
return GroupsFromJson(r.Body), BuildResponse(r)
responseData := struct {
Count int `json:"count"`
Groups []*Group `json:"groups"`
}{}
if err := json.NewDecoder(r.Body).Decode(&responseData); err != nil {
appErr := NewAppError("Api4.GetLdapGroups", "api.marshal_error", nil, err.Error(), http.StatusInternalServerError)
return nil, BuildErrorResponse(r, appErr)
}
for i := range responseData.Groups {
responseData.Groups[i].DisplayName = *responseData.Groups[i].Name
}
return responseData.Groups, BuildResponse(r)
}
// LinkLdapGroup creates or undeletes a Mattermost group and associates it to the given LDAP group DN.