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
This commit is contained in:
@ -10,6 +10,7 @@ import (
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/models/unit"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
|
||||
@ -30,7 +31,7 @@ func init() {
|
||||
db.RegisterModel(new(Collaboration))
|
||||
}
|
||||
|
||||
func (repo *Repository) addCollaborator(e db.Engine, u *User) error {
|
||||
func (repo *Repository) addCollaborator(e db.Engine, u *user_model.User) error {
|
||||
collaboration := &Collaboration{
|
||||
RepoID: repo.ID,
|
||||
UserID: u.ID,
|
||||
@ -52,7 +53,7 @@ func (repo *Repository) addCollaborator(e db.Engine, u *User) error {
|
||||
}
|
||||
|
||||
// AddCollaborator adds new collaboration to a repository with default access mode.
|
||||
func (repo *Repository) AddCollaborator(u *User) error {
|
||||
func (repo *Repository) AddCollaborator(u *user_model.User) error {
|
||||
ctx, committer, err := db.TxContext()
|
||||
if err != nil {
|
||||
return err
|
||||
@ -80,7 +81,7 @@ func (repo *Repository) getCollaborations(e db.Engine, listOptions db.ListOption
|
||||
|
||||
// Collaborator represents a user with collaboration details.
|
||||
type Collaborator struct {
|
||||
*User
|
||||
*user_model.User
|
||||
Collaboration *Collaboration
|
||||
}
|
||||
|
||||
@ -92,11 +93,11 @@ func (repo *Repository) getCollaborators(e db.Engine, listOptions db.ListOptions
|
||||
|
||||
collaborators := make([]*Collaborator, 0, len(collaborations))
|
||||
for _, c := range collaborations {
|
||||
user, err := getUserByID(e, c.UserID)
|
||||
user, err := user_model.GetUserByIDEngine(e, c.UserID)
|
||||
if err != nil {
|
||||
if IsErrUserNotExist(err) {
|
||||
if user_model.IsErrUserNotExist(err) {
|
||||
log.Warn("Inconsistent DB: User: %d is listed as collaborator of %-v but does not exist", c.UserID, repo)
|
||||
user = NewGhostUser()
|
||||
user = user_model.NewGhostUser()
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
@ -227,7 +228,7 @@ func (repo *Repository) DeleteCollaboration(uid int64) (err error) {
|
||||
}
|
||||
|
||||
func (repo *Repository) reconsiderIssueAssignees(e db.Engine, uid int64) error {
|
||||
user, err := getUserByID(e, uid)
|
||||
user, err := user_model.GetUserByIDEngine(e, uid)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user