mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08: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,
 | 
							Location:    user.Location,
 | 
				
			||||||
		Website:     user.Website,
 | 
							Website:     user.Website,
 | 
				
			||||||
		Description: user.Description,
 | 
							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
 | 
						// hide primary email if API caller is anonymous or user keep email private
 | 
				
			||||||
	if signed && (!user.KeepEmailPrivate || authed) {
 | 
						if signed && (!user.KeepEmailPrivate || authed) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -43,6 +43,11 @@ type User struct {
 | 
				
			|||||||
	Website string `json:"website"`
 | 
						Website string `json:"website"`
 | 
				
			||||||
	// the user's description
 | 
						// the user's description
 | 
				
			||||||
	Description string `json:"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
 | 
					// MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16345,6 +16345,17 @@
 | 
				
			|||||||
          "format": "email",
 | 
					          "format": "email",
 | 
				
			||||||
          "x-go-name": "Email"
 | 
					          "x-go-name": "Email"
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
 | 
					        "followers_count": {
 | 
				
			||||||
 | 
					          "description": "user counts",
 | 
				
			||||||
 | 
					          "type": "integer",
 | 
				
			||||||
 | 
					          "format": "int64",
 | 
				
			||||||
 | 
					          "x-go-name": "Followers"
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        "following_count": {
 | 
				
			||||||
 | 
					          "type": "integer",
 | 
				
			||||||
 | 
					          "format": "int64",
 | 
				
			||||||
 | 
					          "x-go-name": "Following"
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
        "full_name": {
 | 
					        "full_name": {
 | 
				
			||||||
          "description": "the user's full name",
 | 
					          "description": "the user's full name",
 | 
				
			||||||
          "type": "string",
 | 
					          "type": "string",
 | 
				
			||||||
@@ -16391,6 +16402,11 @@
 | 
				
			|||||||
          "type": "boolean",
 | 
					          "type": "boolean",
 | 
				
			||||||
          "x-go-name": "Restricted"
 | 
					          "x-go-name": "Restricted"
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
 | 
					        "starred_repos_count": {
 | 
				
			||||||
 | 
					          "type": "integer",
 | 
				
			||||||
 | 
					          "format": "int64",
 | 
				
			||||||
 | 
					          "x-go-name": "StarredRepos"
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
        "website": {
 | 
					        "website": {
 | 
				
			||||||
          "description": "the user's website",
 | 
					          "description": "the user's website",
 | 
				
			||||||
          "type": "string",
 | 
					          "type": "string",
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user