diff --git a/http.go b/http.go index 6198e1c..619f463 100644 --- a/http.go +++ b/http.go @@ -342,4 +342,32 @@ func HttpHandleGroupsGeWithoutMembers(response http.ResponseWriter, request *htt ctx := request.Context() + client, err := CacheGetClientById(clientId) + if err != nil { + client = &Client{Id: clientId} + err = DbSetClientById(ctx, client) + if err != nil { + http.Error(response, "invalid token", http.StatusUnauthorized) + return + } + CacheSaveClient(client) + } + + var groups [MaxGroupsForClient]*Group + var i uint32 + + for groupId := range client.Groups { + group, err := CacheGetGroup(groupId) + if err != nil { + group = &Group{Id: groupId} + err = DbSetClientByIdWithoutGroups(ctx, client) + if err != nil { + http.Error(response, "internal server error", http.StatusInternalServerError) + return + } + groups[i] = group + i++ + } + + } } diff --git a/structs.go b/structs.go index a2d10b1..8bde1ca 100644 --- a/structs.go +++ b/structs.go @@ -27,3 +27,13 @@ type Group struct { Color [3]uint8 EnableClientColors bool } + +type GroupNoMembers struct { + Name string + CreatedAt time.Time + Id uint32 + CreatorId uint32 + OwnerId uint32 + Color [3]uint8 + EnableClientsColors bool +}