summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-11-28 22:11:58 +0800
committerGitHub <noreply@github.com>2021-11-28 22:11:58 +0800
commit9defddb2862aa0a54da21328ca091284291363f7 (patch)
tree1126670579198f00d89c8a4f0240aa7d99995eb8 /services
parentb1df89095163d8ce3eecfeb855e7f03f17b473c4 (diff)
downloadgitea-9defddb2862aa0a54da21328ca091284291363f7.tar.gz
gitea-9defddb2862aa0a54da21328ca091284291363f7.zip
Move more model into models/user (#17826)
* Move more model into models/user * Remove unnecessary comment Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'services')
-rw-r--r--services/auth/login_source.go3
-rw-r--r--services/externalaccount/user.go4
-rw-r--r--services/migrations/gitea_uploader.go18
-rw-r--r--services/migrations/update.go3
4 files changed, 14 insertions, 14 deletions
diff --git a/services/auth/login_source.go b/services/auth/login_source.go
index edce14cd8b..47a687f63b 100644
--- a/services/auth/login_source.go
+++ b/services/auth/login_source.go
@@ -5,7 +5,6 @@
package auth
import (
- "code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/login"
user_model "code.gitea.io/gitea/models/user"
@@ -22,7 +21,7 @@ func DeleteLoginSource(source *login.Source) error {
}
}
- count, err = db.GetEngine(db.DefaultContext).Count(&models.ExternalLoginUser{LoginSourceID: source.ID})
+ count, err = db.GetEngine(db.DefaultContext).Count(&user_model.ExternalLoginUser{LoginSourceID: source.ID})
if err != nil {
return err
} else if count > 0 {
diff --git a/services/externalaccount/user.go b/services/externalaccount/user.go
index c11499d765..f7280e90e4 100644
--- a/services/externalaccount/user.go
+++ b/services/externalaccount/user.go
@@ -22,7 +22,7 @@ func LinkAccountToUser(user *user_model.User, gothUser goth.User) error {
return err
}
- externalLoginUser := &models.ExternalLoginUser{
+ externalLoginUser := &user_model.ExternalLoginUser{
ExternalID: gothUser.UserID,
UserID: user.ID,
LoginSourceID: loginSource.ID,
@@ -42,7 +42,7 @@ func LinkAccountToUser(user *user_model.User, gothUser goth.User) error {
ExpiresAt: gothUser.ExpiresAt,
}
- if err := models.LinkExternalToUser(user, externalLoginUser); err != nil {
+ if err := user_model.LinkExternalToUser(user, externalLoginUser); err != nil {
return err
}
diff --git a/services/migrations/gitea_uploader.go b/services/migrations/gitea_uploader.go
index 3bc8992c3a..4808916c1d 100644
--- a/services/migrations/gitea_uploader.go
+++ b/services/migrations/gitea_uploader.go
@@ -260,7 +260,7 @@ func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error {
tp := g.gitServiceType.Name()
if !ok && tp != "" {
var err error
- userid, err = models.GetUserIDByExternalUserID(tp, fmt.Sprintf("%v", release.PublisherID))
+ userid, err = user_model.GetUserIDByExternalUserID(tp, fmt.Sprintf("%v", release.PublisherID))
if err != nil {
log.Error("GetUserIDByExternalUserID: %v", err)
}
@@ -400,7 +400,7 @@ func (g *GiteaLocalUploader) CreateIssues(issues ...*base.Issue) error {
tp := g.gitServiceType.Name()
if !ok && tp != "" {
var err error
- userid, err = models.GetUserIDByExternalUserID(tp, fmt.Sprintf("%v", issue.PosterID))
+ userid, err = user_model.GetUserIDByExternalUserID(tp, fmt.Sprintf("%v", issue.PosterID))
if err != nil {
log.Error("GetUserIDByExternalUserID: %v", err)
}
@@ -425,7 +425,7 @@ func (g *GiteaLocalUploader) CreateIssues(issues ...*base.Issue) error {
userid, ok := g.userMap[reaction.UserID]
if !ok && tp != "" {
var err error
- userid, err = models.GetUserIDByExternalUserID(tp, fmt.Sprintf("%v", reaction.UserID))
+ userid, err = user_model.GetUserIDByExternalUserID(tp, fmt.Sprintf("%v", reaction.UserID))
if err != nil {
log.Error("GetUserIDByExternalUserID: %v", err)
}
@@ -483,7 +483,7 @@ func (g *GiteaLocalUploader) CreateComments(comments ...*base.Comment) error {
tp := g.gitServiceType.Name()
if !ok && tp != "" {
var err error
- userid, err = models.GetUserIDByExternalUserID(tp, fmt.Sprintf("%v", comment.PosterID))
+ userid, err = user_model.GetUserIDByExternalUserID(tp, fmt.Sprintf("%v", comment.PosterID))
if err != nil {
log.Error("GetUserIDByExternalUserID: %v", err)
}
@@ -520,7 +520,7 @@ func (g *GiteaLocalUploader) CreateComments(comments ...*base.Comment) error {
userid, ok := g.userMap[reaction.UserID]
if !ok && tp != "" {
var err error
- userid, err = models.GetUserIDByExternalUserID(tp, fmt.Sprintf("%v", reaction.UserID))
+ userid, err = user_model.GetUserIDByExternalUserID(tp, fmt.Sprintf("%v", reaction.UserID))
if err != nil {
log.Error("GetUserIDByExternalUserID: %v", err)
}
@@ -564,7 +564,7 @@ func (g *GiteaLocalUploader) CreatePullRequests(prs ...*base.PullRequest) error
tp := g.gitServiceType.Name()
if !ok && tp != "" {
var err error
- userid, err = models.GetUserIDByExternalUserID(tp, fmt.Sprintf("%v", pr.PosterID))
+ userid, err = user_model.GetUserIDByExternalUserID(tp, fmt.Sprintf("%v", pr.PosterID))
if err != nil {
log.Error("GetUserIDByExternalUserID: %v", err)
}
@@ -744,7 +744,7 @@ func (g *GiteaLocalUploader) newPullRequest(pr *base.PullRequest) (*models.PullR
userid, ok := g.userMap[pr.PosterID]
if !ok && tp != "" {
var err error
- userid, err = models.GetUserIDByExternalUserID(tp, fmt.Sprintf("%v", pr.PosterID))
+ userid, err = user_model.GetUserIDByExternalUserID(tp, fmt.Sprintf("%v", pr.PosterID))
if err != nil {
log.Error("GetUserIDByExternalUserID: %v", err)
}
@@ -766,7 +766,7 @@ func (g *GiteaLocalUploader) newPullRequest(pr *base.PullRequest) (*models.PullR
userid, ok := g.userMap[reaction.UserID]
if !ok && tp != "" {
var err error
- userid, err = models.GetUserIDByExternalUserID(tp, fmt.Sprintf("%v", reaction.UserID))
+ userid, err = user_model.GetUserIDByExternalUserID(tp, fmt.Sprintf("%v", reaction.UserID))
if err != nil {
log.Error("GetUserIDByExternalUserID: %v", err)
}
@@ -850,7 +850,7 @@ func (g *GiteaLocalUploader) CreateReviews(reviews ...*base.Review) error {
tp := g.gitServiceType.Name()
if !ok && tp != "" {
var err error
- userid, err = models.GetUserIDByExternalUserID(tp, fmt.Sprintf("%v", review.ReviewerID))
+ userid, err = user_model.GetUserIDByExternalUserID(tp, fmt.Sprintf("%v", review.ReviewerID))
if err != nil {
log.Error("GetUserIDByExternalUserID: %v", err)
}
diff --git a/services/migrations/update.go b/services/migrations/update.go
index ddc9401ead..cdec73cd1b 100644
--- a/services/migrations/update.go
+++ b/services/migrations/update.go
@@ -9,6 +9,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
+ user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/structs"
)
@@ -45,7 +46,7 @@ func updateMigrationPosterIDByGitService(ctx context.Context, tp structs.GitServ
default:
}
- users, err := models.FindExternalUsersByProvider(models.FindExternalUserOptions{
+ users, err := user_model.FindExternalUsersByProvider(user_model.FindExternalUserOptions{
Provider: provider,
Start: start,
Limit: batchSize,