diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-11-24 17:49:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-24 17:49:20 +0800 |
commit | a666829a37be6f9fd98f9e7dd1767c420f7f3b32 (patch) | |
tree | 9ab1434b759a8a2cb275a83149903a823851e309 /modules/convert/user.go | |
parent | 4e7ca946da2a2642a62f114825129bf5d7ed9196 (diff) | |
download | gitea-a666829a37be6f9fd98f9e7dd1767c420f7f3b32.tar.gz gitea-a666829a37be6f9fd98f9e7dd1767c420f7f3b32.zip |
Move user related model into models/user (#17781)
* Move user related model into models/user
* Fix lint for windows
* Fix windows lint
* Fix windows lint
* Move some tests in models
* Merge
Diffstat (limited to 'modules/convert/user.go')
-rw-r--r-- | modules/convert/user.go | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/modules/convert/user.go b/modules/convert/user.go index 3f17ae4b4d..ebe2f06460 100644 --- a/modules/convert/user.go +++ b/modules/convert/user.go @@ -6,12 +6,13 @@ package convert import ( "code.gitea.io/gitea/models" + user_model "code.gitea.io/gitea/models/user" api "code.gitea.io/gitea/modules/structs" ) -// ToUser convert models.User to api.User +// ToUser convert user_model.User to api.User // if doer is set, private information is added if the doer has the permission to see it -func ToUser(user, doer *models.User) *api.User { +func ToUser(user, doer *user_model.User) *api.User { if user == nil { return nil } @@ -24,8 +25,8 @@ func ToUser(user, doer *models.User) *api.User { return toUser(user, signed, authed) } -// ToUsers convert list of models.User to list of api.User -func ToUsers(doer *models.User, users []*models.User) []*api.User { +// ToUsers convert list of user_model.User to list of api.User +func ToUsers(doer *user_model.User, users []*user_model.User) []*api.User { result := make([]*api.User, len(users)) for i := range users { result[i] = ToUser(users[i], doer) @@ -33,18 +34,18 @@ func ToUsers(doer *models.User, users []*models.User) []*api.User { return result } -// ToUserWithAccessMode convert models.User to api.User +// ToUserWithAccessMode convert user_model.User to api.User // AccessMode is not none show add some more information -func ToUserWithAccessMode(user *models.User, accessMode models.AccessMode) *api.User { +func ToUserWithAccessMode(user *user_model.User, accessMode models.AccessMode) *api.User { if user == nil { return nil } return toUser(user, accessMode != models.AccessModeNone, false) } -// toUser convert models.User to api.User +// toUser convert user_model.User to api.User // signed shall only be set if requester is logged in. authed shall only be set if user is site admin or user himself -func toUser(user *models.User, signed, authed bool) *api.User { +func toUser(user *user_model.User, signed, authed bool) *api.User { result := &api.User{ ID: user.ID, UserName: user.Name, @@ -81,7 +82,7 @@ func toUser(user *models.User, signed, authed bool) *api.User { } // User2UserSettings return UserSettings based on a user -func User2UserSettings(user *models.User) api.UserSettings { +func User2UserSettings(user *user_model.User) api.UserSettings { return api.UserSettings{ FullName: user.FullName, Website: user.Website, |