mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-07-06 13:00:03 +02: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:
parent
131278ff22
commit
d453533beb
28 changed files with 234 additions and 208 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue