mirror of
https://github.com/go-gitea/gitea.git
synced 2025-06-21 21:48:00 +02:00
[API] User expose counters (#16167)
This commit is contained in:
@ -48,6 +48,10 @@ func toUser(user *models.User, signed, authed bool) *api.User {
|
||||
Location: user.Location,
|
||||
Website: user.Website,
|
||||
Description: user.Description,
|
||||
// counter's
|
||||
Followers: user.NumFollowers,
|
||||
Following: user.NumFollowing,
|
||||
StarredRepos: user.NumStars,
|
||||
}
|
||||
// hide primary email if API caller is anonymous or user keep email private
|
||||
if signed && (!user.KeepEmailPrivate || authed) {
|
||||
|
@ -43,6 +43,11 @@ type User struct {
|
||||
Website string `json:"website"`
|
||||
// the user's description
|
||||
Description string `json:"description"`
|
||||
|
||||
// user counts
|
||||
Followers int `json:"followers_count"`
|
||||
Following int `json:"following_count"`
|
||||
StarredRepos int `json:"starred_repos_count"`
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility
|
||||
|
Reference in New Issue
Block a user