mirror of
https://github.com/coder/coder.git
synced 2025-07-12 00:14:10 +00:00
fix!: omit name, avatar_url and last_seen_at from responses when empty (#18005)
User name, avatar URL, and last seen at, are not required fields so they can be empty. Instead of returning the 0 values from Go, we want to make it more agnostic, and omit them when they are empty. This make the docs and usage way clearer for consumers.
This commit is contained in:
@ -40,7 +40,7 @@ type UsersRequest struct {
|
||||
type MinimalUser struct {
|
||||
ID uuid.UUID `json:"id" validate:"required" table:"id" format:"uuid"`
|
||||
Username string `json:"username" validate:"required" table:"username,default_sort"`
|
||||
AvatarURL string `json:"avatar_url" format:"uri"`
|
||||
AvatarURL string `json:"avatar_url,omitempty" format:"uri"`
|
||||
}
|
||||
|
||||
// ReducedUser omits role and organization information. Roles are deduced from
|
||||
@ -49,11 +49,11 @@ type MinimalUser struct {
|
||||
// required by the frontend.
|
||||
type ReducedUser struct {
|
||||
MinimalUser `table:"m,recursive_inline"`
|
||||
Name string `json:"name"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Email string `json:"email" validate:"required" table:"email" format:"email"`
|
||||
CreatedAt time.Time `json:"created_at" validate:"required" table:"created at" format:"date-time"`
|
||||
UpdatedAt time.Time `json:"updated_at" table:"updated at" format:"date-time"`
|
||||
LastSeenAt time.Time `json:"last_seen_at" format:"date-time"`
|
||||
LastSeenAt time.Time `json:"last_seen_at,omitempty" format:"date-time"`
|
||||
|
||||
Status UserStatus `json:"status" table:"status" enums:"active,suspended"`
|
||||
LoginType LoginType `json:"login_type"`
|
||||
|
Reference in New Issue
Block a user