aboutsummaryrefslogtreecommitdiff
path: root/internal/db/user.go
diff options
context:
space:
mode:
authorJoe Chen <jc@unknwon.io>2022-06-25 18:07:39 +0800
committerGitHub <noreply@github.com>2022-06-25 18:07:39 +0800
commit083c3ee659c6c5542687f3bafae68cbc24dbc90f (patch)
tree0103bf3b5c5ebfccd368a7cb6a425a521fd669d9 /internal/db/user.go
parent9df4e3ae3c555a86f691f0d78a43834842e77d8b (diff)
db: refactor "action" table to use GORM (#7054)
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
Diffstat (limited to 'internal/db/user.go')
-rw-r--r--internal/db/user.go28
1 files changed, 15 insertions, 13 deletions
diff --git a/internal/db/user.go b/internal/db/user.go
index 1ad4b955..97e2800f 100644
--- a/internal/db/user.go
+++ b/internal/db/user.go
@@ -49,14 +49,14 @@ const (
// User represents the object of individual and member of organization.
type User struct {
- ID int64
- LowerName string `xorm:"UNIQUE NOT NULL" gorm:"UNIQUE"`
- Name string `xorm:"UNIQUE NOT NULL" gorm:"NOT NULL"`
+ ID int64 `gorm:"primaryKey"`
+ LowerName string `xorm:"UNIQUE NOT NULL" gorm:"unique;not null"`
+ Name string `xorm:"UNIQUE NOT NULL" gorm:"not null"`
FullName string
// Email is the primary email address (to be used for communication)
- Email string `xorm:"NOT NULL" gorm:"NOT NULL"`
- Passwd string `xorm:"NOT NULL" gorm:"NOT NULL"`
- LoginSource int64 `xorm:"NOT NULL DEFAULT 0" gorm:"NOT NULL;DEFAULT:0"`
+ Email string `xorm:"NOT NULL" gorm:"not null"`
+ Passwd string `xorm:"NOT NULL" gorm:"not null"`
+ LoginSource int64 `xorm:"NOT NULL DEFAULT 0" gorm:"not null;default:0"`
LoginName string
Type UserType
OwnedOrgs []*User `xorm:"-" gorm:"-" json:"-"`
@@ -64,8 +64,8 @@ type User struct {
Repos []*Repository `xorm:"-" gorm:"-" json:"-"`
Location string
Website string
- Rands string `xorm:"VARCHAR(10)" gorm:"TYPE:VARCHAR(10)"`
- Salt string `xorm:"VARCHAR(10)" gorm:"TYPE:VARCHAR(10)"`
+ Rands string `xorm:"VARCHAR(10)" gorm:"type:VARCHAR(10)"`
+ Salt string `xorm:"VARCHAR(10)" gorm:"type:VARCHAR(10)"`
Created time.Time `xorm:"-" gorm:"-" json:"-"`
CreatedUnix int64
@@ -75,7 +75,7 @@ type User struct {
// Remember visibility choice for convenience, true for private
LastRepoVisibility bool
// Maximum repository creation limit, -1 means use global default
- MaxRepoCreation int `xorm:"NOT NULL DEFAULT -1" gorm:"NOT NULL;DEFAULT:-1"`
+ MaxRepoCreation int `xorm:"NOT NULL DEFAULT -1" gorm:"not null;default:-1"`
// Permissions
IsActive bool // Activate primary email
@@ -85,13 +85,13 @@ type User struct {
ProhibitLogin bool
// Avatar
- Avatar string `xorm:"VARCHAR(2048) NOT NULL" gorm:"TYPE:VARCHAR(2048);NOT NULL"`
- AvatarEmail string `xorm:"NOT NULL" gorm:"NOT NULL"`
+ Avatar string `xorm:"VARCHAR(2048) NOT NULL" gorm:"type:VARCHAR(2048);not null"`
+ AvatarEmail string `xorm:"NOT NULL" gorm:"not null"`
UseCustomAvatar bool
// Counters
NumFollowers int
- NumFollowing int `xorm:"NOT NULL DEFAULT 0" gorm:"NOT NULL;DEFAULT:0"`
+ NumFollowing int `xorm:"NOT NULL DEFAULT 0" gorm:"not null;default:0"`
NumStars int
NumRepos int
@@ -466,7 +466,7 @@ func (u *User) DisplayName() string {
}
func (u *User) ShortName(length int) string {
- return tool.EllipsisString(u.Name, length)
+ return strutil.Ellipsis(u.Name, length)
}
// IsMailable checks if a user is eligible
@@ -908,6 +908,8 @@ func DeleteInactivateUsers() (err error) {
}
// UserPath returns the path absolute path of user repositories.
+//
+// Deprecated: Use repoutil.UserPath instead.
func UserPath(username string) string {
return filepath.Join(conf.Repository.Root, strings.ToLower(username))
}