Fix saving of tags on users
This commit is contained in:
parent
945b482b00
commit
af2299f417
2 changed files with 12 additions and 3 deletions
|
|
@ -30,11 +30,12 @@ type User struct {
|
|||
DisplayName string
|
||||
ID int
|
||||
Initials string
|
||||
IsDronePilot bool
|
||||
IsWarrant bool
|
||||
Organization Organization
|
||||
PasswordHash string
|
||||
PasswordHashType string
|
||||
Role string
|
||||
Tags []string
|
||||
Username string
|
||||
|
||||
model *models.User
|
||||
|
|
@ -61,11 +62,12 @@ func newUser(ctx context.Context, org Organization, user *models.User) User {
|
|||
DisplayName: user.DisplayName,
|
||||
ID: int(user.ID),
|
||||
Initials: extractInitials(user.DisplayName),
|
||||
IsDronePilot: user.IsDronePilot,
|
||||
IsWarrant: user.IsWarrant,
|
||||
Organization: org,
|
||||
PasswordHash: user.PasswordHash,
|
||||
PasswordHashType: string(user.PasswordHashType),
|
||||
Role: user.Role.String(),
|
||||
Tags: []string{},
|
||||
Username: user.Username,
|
||||
|
||||
model: user,
|
||||
|
|
|
|||
|
|
@ -48,6 +48,13 @@ func (res *userR) response(u *platform.User) (*user, error) {
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("id to uri: %w", err)
|
||||
}
|
||||
tags := make([]string, 0)
|
||||
if u.IsDronePilot {
|
||||
tags = append(tags, "drone pilot")
|
||||
}
|
||||
if u.IsWarrant {
|
||||
tags = append(tags, "warrant")
|
||||
}
|
||||
return &user{
|
||||
Avatar: omitnull.FromPtr(avatar),
|
||||
DisplayName: omit.From(u.DisplayName),
|
||||
|
|
@ -55,7 +62,7 @@ func (res *userR) response(u *platform.User) (*user, error) {
|
|||
Initials: omit.From(u.Initials),
|
||||
IsActive: omit.From(u.Active),
|
||||
Role: omit.From(u.Role),
|
||||
Tags: omit.From(u.Tags),
|
||||
Tags: omit.From(tags),
|
||||
URI: omit.From(uri),
|
||||
Username: omit.From(u.Username),
|
||||
}, nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue