You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
888 B
Go
44 lines
888 B
Go
2 years ago
|
package lista_utenti
|
||
|
|
||
|
import (
|
||
|
"git.phc.dm.unipi.it/phc/website/auth"
|
||
|
"git.phc.dm.unipi.it/phc/website/model"
|
||
|
"git.phc.dm.unipi.it/phc/website/util"
|
||
|
)
|
||
|
|
||
|
type authListaUtenti struct {
|
||
|
AuthService auth.Service
|
||
|
|
||
|
Macchinisti util.Set[string]
|
||
|
}
|
||
|
|
||
|
func newAuthListaUtenti(authService auth.Service) (Service, error) {
|
||
|
macchinisti, err := loadMacchinisti()
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
return &authListaUtenti{authService, macchinisti}, nil
|
||
|
}
|
||
|
|
||
|
func (a *authListaUtenti) GetUtenti() ([]*model.ListUser, error) {
|
||
|
authUsers, err := a.AuthService.GetUsers()
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
users := make([]*model.ListUser, 0, len(authUsers))
|
||
|
for _, u := range authUsers {
|
||
|
users = append(users, &model.ListUser{
|
||
|
Uid: u.Username,
|
||
|
Nome: u.Name,
|
||
|
Cognome: u.Surname,
|
||
|
Tags: []string{},
|
||
|
})
|
||
|
}
|
||
|
|
||
|
mergeMacchinisti(users, a.Macchinisti)
|
||
|
|
||
|
return users, nil
|
||
|
}
|