diff options
author | zeripath <art27@cantab.net> | 2019-04-15 17:36:59 +0100 |
---|---|---|
committer | techknowlogick <matti@mdranta.net> | 2019-04-15 12:36:59 -0400 |
commit | 837116875efc8f27265e884499ecca69ef554014 (patch) | |
tree | 78f6b246216be0f98ac32c3e2b35b831cd840eac /routers/api/v1/convert | |
parent | 74fc63682c4c14b5c19c46f9d41af1cf4212766f (diff) | |
download | gitea-837116875efc8f27265e884499ecca69ef554014.tar.gz gitea-837116875efc8f27265e884499ecca69ef554014.zip |
Return a UserList from /api/v1/admin/users (#6629)
Diffstat (limited to 'routers/api/v1/convert')
-rw-r--r-- | routers/api/v1/convert/convert.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/routers/api/v1/convert/convert.go b/routers/api/v1/convert/convert.go index 14344e581c..d9cc2da7a5 100644 --- a/routers/api/v1/convert/convert.go +++ b/routers/api/v1/convert/convert.go @@ -10,6 +10,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/util" api "code.gitea.io/sdk/gitea" @@ -216,3 +217,18 @@ func ToTeam(team *models.Team) *api.Team { Units: team.GetUnitNames(), } } + +// ToUser convert models.User to api.User +func ToUser(user *models.User, signed, admin bool) *api.User { + result := &api.User{ + ID: user.ID, + UserName: user.Name, + AvatarURL: user.AvatarLink(), + FullName: markup.Sanitize(user.FullName), + IsAdmin: user.IsAdmin, + } + if signed && (!user.KeepEmailPrivate || admin) { + result.Email = user.Email + } + return result +} |