Refactor user struct and user info handling for improved readability
This commit is contained in:
@@ -63,12 +63,12 @@ func (sa StringArray) Value() (driver.Value, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
ID uuid.UUID `json:"id"`
|
ID uuid.UUID `json:"id"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
DisplayName string `json:"displayName"`
|
DisplayName string `json:"displayName"`
|
||||||
PasswordHash *string `json:"-"`
|
PasswordHash *string `json:"-"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
LastLoginAt *time.Time `json:"lastLoginAt"`
|
LastLoginAt *time.Time `json:"lastLoginAt"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -922,15 +922,15 @@ func listMembersHandler(w http.ResponseWriter, r *http.Request, db *database.DB)
|
|||||||
Role: m.Membership.Role,
|
Role: m.Membership.Role,
|
||||||
CreatedAt: m.Membership.CreatedAt,
|
CreatedAt: m.Membership.CreatedAt,
|
||||||
User: userInfo{
|
User: userInfo{
|
||||||
ID: m.User.ID.String(),
|
ID: m.User.ID.String(),
|
||||||
Username: m.User.Username,
|
Username: m.User.Username,
|
||||||
DisplayName: func() *string {
|
DisplayName: func() *string {
|
||||||
if m.User.DisplayName == "" {
|
if m.User.DisplayName == "" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return &m.User.DisplayName
|
return &m.User.DisplayName
|
||||||
}(),
|
}(),
|
||||||
Email: m.User.Email,
|
Email: m.User.Email,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1194,15 +1194,15 @@ func listJoinRequestsHandler(w http.ResponseWriter, r *http.Request, db *databas
|
|||||||
RequestedAt: req.JoinRequest.RequestedAt,
|
RequestedAt: req.JoinRequest.RequestedAt,
|
||||||
Status: req.JoinRequest.Status,
|
Status: req.JoinRequest.Status,
|
||||||
User: userInfo{
|
User: userInfo{
|
||||||
ID: req.User.ID.String(),
|
ID: req.User.ID.String(),
|
||||||
Username: req.User.Username,
|
Username: req.User.Username,
|
||||||
DisplayName: func() *string {
|
DisplayName: func() *string {
|
||||||
if req.User.DisplayName == "" {
|
if req.User.DisplayName == "" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return &req.User.DisplayName
|
return &req.User.DisplayName
|
||||||
}(),
|
}(),
|
||||||
Email: req.User.Email,
|
Email: req.User.Email,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user