mirror of
https://github.com/go-gitea/gitea
synced 2024-11-16 23:11:10 +01:00
Add Location, Website and Biography to API (#15675)
This commit is contained in:
parent
5811e162ae
commit
67e10397af
3 changed files with 31 additions and 7 deletions
|
@ -38,13 +38,16 @@ func ToUserWithAccessMode(user *models.User, accessMode models.AccessMode) *api.
|
||||||
// signed shall only be set if requester is logged in. authed shall only be set if user is site admin or user himself
|
// signed shall only be set if requester is logged in. authed shall only be set if user is site admin or user himself
|
||||||
func toUser(user *models.User, signed, authed bool) *api.User {
|
func toUser(user *models.User, signed, authed bool) *api.User {
|
||||||
result := &api.User{
|
result := &api.User{
|
||||||
ID: user.ID,
|
ID: user.ID,
|
||||||
UserName: user.Name,
|
UserName: user.Name,
|
||||||
FullName: markup.Sanitize(user.FullName),
|
FullName: markup.Sanitize(user.FullName),
|
||||||
Email: user.GetEmail(),
|
Email: user.GetEmail(),
|
||||||
AvatarURL: user.AvatarLink(),
|
AvatarURL: user.AvatarLink(),
|
||||||
Created: user.CreatedUnix.AsTime(),
|
Created: user.CreatedUnix.AsTime(),
|
||||||
Restricted: user.IsRestricted,
|
Restricted: user.IsRestricted,
|
||||||
|
Location: user.Location,
|
||||||
|
Website: user.Website,
|
||||||
|
Description: user.Description,
|
||||||
}
|
}
|
||||||
// hide primary email if API caller is anonymous or user keep email private
|
// hide primary email if API caller is anonymous or user keep email private
|
||||||
if signed && (!user.KeepEmailPrivate || authed) {
|
if signed && (!user.KeepEmailPrivate || authed) {
|
||||||
|
|
|
@ -33,6 +33,12 @@ type User struct {
|
||||||
Created time.Time `json:"created,omitempty"`
|
Created time.Time `json:"created,omitempty"`
|
||||||
// Is user restricted
|
// Is user restricted
|
||||||
Restricted bool `json:"restricted"`
|
Restricted bool `json:"restricted"`
|
||||||
|
// the user's location
|
||||||
|
Location string `json:"location"`
|
||||||
|
// the user's website
|
||||||
|
Website string `json:"website"`
|
||||||
|
// the user's biography
|
||||||
|
Description string `json:"bio"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility
|
// MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility
|
||||||
|
|
|
@ -16251,6 +16251,11 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "AvatarURL"
|
"x-go-name": "AvatarURL"
|
||||||
},
|
},
|
||||||
|
"bio": {
|
||||||
|
"description": "the user's biography",
|
||||||
|
"type": "string",
|
||||||
|
"x-go-name": "Description"
|
||||||
|
},
|
||||||
"created": {
|
"created": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "date-time",
|
"format": "date-time",
|
||||||
|
@ -16287,6 +16292,11 @@
|
||||||
"format": "date-time",
|
"format": "date-time",
|
||||||
"x-go-name": "LastLogin"
|
"x-go-name": "LastLogin"
|
||||||
},
|
},
|
||||||
|
"location": {
|
||||||
|
"description": "the user's location",
|
||||||
|
"type": "string",
|
||||||
|
"x-go-name": "Location"
|
||||||
|
},
|
||||||
"login": {
|
"login": {
|
||||||
"description": "the user's username",
|
"description": "the user's username",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -16296,6 +16306,11 @@
|
||||||
"description": "Is user restricted",
|
"description": "Is user restricted",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"x-go-name": "Restricted"
|
"x-go-name": "Restricted"
|
||||||
|
},
|
||||||
|
"website": {
|
||||||
|
"description": "the user's website",
|
||||||
|
"type": "string",
|
||||||
|
"x-go-name": "Website"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||||
|
|
Loading…
Reference in a new issue