mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 10:18:38 +00:00
[Refactor] Move APIFormat functions into convert package (#12856)
* USER APIFormat -> ToUser * Migrate more and mark APIFormat deprecated * models.Comment APIFormat() -> convert.ToComment * models.Release APIFormat() -> convert.ToRelease * models.Attachments APIFormat() -> convert.ToReleaseAttachments * models.CommitStatus APIFormat() -> convert.ToCommitStatus * finish migration to convert.ToUser * Move Test * Imprufe Test * fix test Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
@@ -29,7 +29,6 @@ import (
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/storage"
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
|
||||
@@ -241,24 +240,6 @@ func GetAllUsers() ([]*User, error) {
|
||||
return users, x.OrderBy("id").Find(&users)
|
||||
}
|
||||
|
||||
// APIFormat converts a User to api.User
|
||||
func (u *User) APIFormat() *api.User {
|
||||
if u == nil {
|
||||
return nil
|
||||
}
|
||||
return &api.User{
|
||||
ID: u.ID,
|
||||
UserName: u.Name,
|
||||
FullName: u.FullName,
|
||||
Email: u.GetEmail(),
|
||||
AvatarURL: u.AvatarLink(),
|
||||
Language: u.Language,
|
||||
IsAdmin: u.IsAdmin,
|
||||
LastLogin: u.LastLoginUnix.AsTime(),
|
||||
Created: u.CreatedUnix.AsTime(),
|
||||
}
|
||||
}
|
||||
|
||||
// IsLocal returns true if user login type is LoginPlain.
|
||||
func (u *User) IsLocal() bool {
|
||||
return u.LoginType <= LoginPlain
|
||||
|
Reference in New Issue
Block a user