mirror of
https://github.com/go-gitea/gitea
synced 2025-12-07 13:28:25 +00:00
Merge remote-tracking branch 'upstream/master' into team-grant-all-repos
# Conflicts: # models/migrations/migrations.go # models/migrations/v90.go # models/repo.go
This commit is contained in:
@@ -15,7 +15,7 @@ import (
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
|
||||
"github.com/Unknwon/com"
|
||||
"github.com/unknwon/com"
|
||||
)
|
||||
|
||||
// ToEmail convert models.EmailAddress to api.Email
|
||||
@@ -206,14 +206,15 @@ func ToDeployKey(apiLink string, key *models.DeployKey) *api.DeployKey {
|
||||
// ToOrganization convert models.User to api.Organization
|
||||
func ToOrganization(org *models.User) *api.Organization {
|
||||
return &api.Organization{
|
||||
ID: org.ID,
|
||||
AvatarURL: org.AvatarLink(),
|
||||
UserName: org.Name,
|
||||
FullName: org.FullName,
|
||||
Description: org.Description,
|
||||
Website: org.Website,
|
||||
Location: org.Location,
|
||||
Visibility: org.Visibility.String(),
|
||||
ID: org.ID,
|
||||
AvatarURL: org.AvatarLink(),
|
||||
UserName: org.Name,
|
||||
FullName: org.FullName,
|
||||
Description: org.Description,
|
||||
Website: org.Website,
|
||||
Location: org.Location,
|
||||
Visibility: org.Visibility.String(),
|
||||
RepoAdminChangeTeamAccess: org.RepoAdminChangeTeamAccess,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,7 +231,7 @@ func ToTeam(team *models.Team) *api.Team {
|
||||
}
|
||||
|
||||
// ToUser convert models.User to api.User
|
||||
func ToUser(user *models.User, signed, admin bool) *api.User {
|
||||
func ToUser(user *models.User, signed, authed bool) *api.User {
|
||||
result := &api.User{
|
||||
ID: user.ID,
|
||||
UserName: user.Name,
|
||||
@@ -240,7 +241,12 @@ func ToUser(user *models.User, signed, admin bool) *api.User {
|
||||
LastLogin: user.LastLoginUnix.AsTime(),
|
||||
Created: user.CreatedUnix.AsTime(),
|
||||
}
|
||||
if signed && (!user.KeepEmailPrivate || admin) {
|
||||
// hide primary email if API caller isn't user itself or an admin
|
||||
if !signed {
|
||||
result.Email = ""
|
||||
} else if user.KeepEmailPrivate && !authed {
|
||||
result.Email = user.GetEmail()
|
||||
} else {
|
||||
result.Email = user.Email
|
||||
}
|
||||
return result
|
||||
@@ -287,3 +293,14 @@ func ToCommitMeta(repo *models.Repository, tag *git.Tag) *api.CommitMeta {
|
||||
URL: util.URLJoin(repo.APIURL(), "git/commits", tag.ID.String()),
|
||||
}
|
||||
}
|
||||
|
||||
// ToTopicResponse convert from models.Topic to api.TopicResponse
|
||||
func ToTopicResponse(topic *models.Topic) *api.TopicResponse {
|
||||
return &api.TopicResponse{
|
||||
ID: topic.ID,
|
||||
Name: topic.Name,
|
||||
RepoCount: topic.RepoCount,
|
||||
Created: topic.CreatedUnix.AsTime(),
|
||||
Updated: topic.UpdatedUnix.AsTime(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user