MM-16258: Adds new API endpoint + (App & Client & Store) to retrieve … (#11176)

* MM-16258: Adds new API endpoint + (App & Client & Store) to retrieve Users who would be removed from a list of hypothetical group IDs representing the synced groups.

* MM-16258: Adds roles to JSON response.

* MM-16258: Updates GetByIDs to use Squirrel.

* MM-16258: Puts as much as possible into Squirrel.

* MM-16258: Changes names of methods, functions, and route.

* MM-16258: Updates some comments.

* MM-16258: Extra validation of group_ids parameter.

* MM-16258: Changes validation of group_ids query param.

* MM-16258: Rename a variable and a constant.

* MM-16258: Fix test.
Этот коммит содержится в:
Martin Kraft
2019-06-17 09:51:56 -04:00
коммит произвёл GitHub
родитель 5ee1f6e2e0
Коммит 9d41c7a583
10 изменённых файлов: 615 добавлений и 0 удалений

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

@@ -8,6 +8,7 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"regexp"
"sort"
@@ -768,3 +769,24 @@ func IsValidLocale(locale string) bool {
return true
}
type UserWithGroups struct {
User
GroupIDs string `json:"-"`
Groups []*Group `json:"groups"`
SchemeGuest bool `json:"scheme_guest"`
SchemeUser bool `json:"scheme_user"`
SchemeAdmin bool `json:"scheme_admin"`
}
type UsersWithGroupsAndCount struct {
Users []*UserWithGroups `json:"users"`
Count int64 `json:"total_count"`
}
func UsersWithGroupsAndCountFromJson(data io.Reader) *UsersWithGroupsAndCount {
uwg := &UsersWithGroupsAndCount{}
bodyBytes, _ := ioutil.ReadAll(data)
json.Unmarshal(bodyBytes, uwg)
return uwg
}