Skip to content

Commit 67e1039

Browse files
authored
Add Location, Website and Biography to API (#15675)
1 parent 5811e16 commit 67e1039

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

modules/convert/user.go

+10-7
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,16 @@ func ToUserWithAccessMode(user *models.User, accessMode models.AccessMode) *api.
3838
// signed shall only be set if requester is logged in. authed shall only be set if user is site admin or user himself
3939
func toUser(user *models.User, signed, authed bool) *api.User {
4040
result := &api.User{
41-
ID: user.ID,
42-
UserName: user.Name,
43-
FullName: markup.Sanitize(user.FullName),
44-
Email: user.GetEmail(),
45-
AvatarURL: user.AvatarLink(),
46-
Created: user.CreatedUnix.AsTime(),
47-
Restricted: user.IsRestricted,
41+
ID: user.ID,
42+
UserName: user.Name,
43+
FullName: markup.Sanitize(user.FullName),
44+
Email: user.GetEmail(),
45+
AvatarURL: user.AvatarLink(),
46+
Created: user.CreatedUnix.AsTime(),
47+
Restricted: user.IsRestricted,
48+
Location: user.Location,
49+
Website: user.Website,
50+
Description: user.Description,
4851
}
4952
// hide primary email if API caller is anonymous or user keep email private
5053
if signed && (!user.KeepEmailPrivate || authed) {

modules/structs/user.go

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ type User struct {
3333
Created time.Time `json:"created,omitempty"`
3434
// Is user restricted
3535
Restricted bool `json:"restricted"`
36+
// the user's location
37+
Location string `json:"location"`
38+
// the user's website
39+
Website string `json:"website"`
40+
// the user's biography
41+
Description string `json:"bio"`
3642
}
3743

3844
// MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility

templates/swagger/v1_json.tmpl

+15
Original file line numberDiff line numberDiff line change
@@ -16251,6 +16251,11 @@
1625116251
"type": "string",
1625216252
"x-go-name": "AvatarURL"
1625316253
},
16254+
"bio": {
16255+
"description": "the user's biography",
16256+
"type": "string",
16257+
"x-go-name": "Description"
16258+
},
1625416259
"created": {
1625516260
"type": "string",
1625616261
"format": "date-time",
@@ -16287,6 +16292,11 @@
1628716292
"format": "date-time",
1628816293
"x-go-name": "LastLogin"
1628916294
},
16295+
"location": {
16296+
"description": "the user's location",
16297+
"type": "string",
16298+
"x-go-name": "Location"
16299+
},
1629016300
"login": {
1629116301
"description": "the user's username",
1629216302
"type": "string",
@@ -16296,6 +16306,11 @@
1629616306
"description": "Is user restricted",
1629716307
"type": "boolean",
1629816308
"x-go-name": "Restricted"
16309+
},
16310+
"website": {
16311+
"description": "the user's website",
16312+
"type": "string",
16313+
"x-go-name": "Website"
1629916314
}
1630016315
},
1630116316
"x-go-package": "code.gitea.io/gitea/modules/structs"

0 commit comments

Comments
 (0)