summaryrefslogtreecommitdiffstats
path: root/models/repo_collaboration.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-11-24 17:49:20 +0800
committerGitHub <noreply@github.com>2021-11-24 17:49:20 +0800
commita666829a37be6f9fd98f9e7dd1767c420f7f3b32 (patch)
tree9ab1434b759a8a2cb275a83149903a823851e309 /models/repo_collaboration.go
parent4e7ca946da2a2642a62f114825129bf5d7ed9196 (diff)
downloadgitea-a666829a37be6f9fd98f9e7dd1767c420f7f3b32.tar.gz
gitea-a666829a37be6f9fd98f9e7dd1767c420f7f3b32.zip
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
Diffstat (limited to 'models/repo_collaboration.go')
-rw-r--r--models/repo_collaboration.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/models/repo_collaboration.go b/models/repo_collaboration.go
index 6502d7959c..11d1a0e1d0 100644
--- a/models/repo_collaboration.go
+++ b/models/repo_collaboration.go
@@ -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
}