diff options
Diffstat (limited to 'models/user.go')
-rw-r--r-- | models/user.go | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/models/user.go b/models/user.go index d08b1cc8fa..7ec5e12b2f 100644 --- a/models/user.go +++ b/models/user.go @@ -25,6 +25,7 @@ import ( "github.com/nfnt/resize" "github.com/gogits/git-module" + api "github.com/gogits/go-gogs-client" "github.com/gogits/gogs/modules/avatar" "github.com/gogits/gogs/modules/base" @@ -130,6 +131,16 @@ func (u *User) AfterSet(colName string, _ xorm.Cell) { } } +func (u *User) APIFormat() *api.User { + return &api.User{ + ID: u.ID, + UserName: u.Name, + FullName: u.FullName, + Email: u.Email, + AvatarUrl: u.AvatarLink(), + } +} + // returns true if user login type is LOGIN_PLAIN. func (u *User) IsLocal() bool { return u.LoginType <= LOGIN_PLAIN @@ -468,12 +479,12 @@ func GetUserSalt() string { return base.GetRandomString(10) } -// NewFakeUser creates and returns a fake user for someone has deleted his/her account. -func NewFakeUser() *User { +// NewGhostUser creates and returns a fake user for someone has deleted his/her account. +func NewGhostUser() *User { return &User{ ID: -1, - Name: "Someone", - LowerName: "someone", + Name: "Ghost", + LowerName: "ghost", } } |