diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-11-24 17:49:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-24 17:49:20 +0800 |
commit | a666829a37be6f9fd98f9e7dd1767c420f7f3b32 (patch) | |
tree | 9ab1434b759a8a2cb275a83149903a823851e309 /models/review.go | |
parent | 4e7ca946da2a2642a62f114825129bf5d7ed9196 (diff) | |
download | gitea-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/review.go')
-rw-r--r-- | models/review.go | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/models/review.go b/models/review.go index 00906c7a27..1c4943f699 100644 --- a/models/review.go +++ b/models/review.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/base" "code.gitea.io/gitea/modules/timeutil" @@ -55,10 +56,10 @@ func (rt ReviewType) Icon() string { type Review struct { ID int64 `xorm:"pk autoincr"` Type ReviewType - Reviewer *User `xorm:"-"` - ReviewerID int64 `xorm:"index"` - ReviewerTeamID int64 `xorm:"NOT NULL DEFAULT 0"` - ReviewerTeam *Team `xorm:"-"` + Reviewer *user_model.User `xorm:"-"` + ReviewerID int64 `xorm:"index"` + ReviewerTeamID int64 `xorm:"NOT NULL DEFAULT 0"` + ReviewerTeam *Team `xorm:"-"` OriginalAuthor string OriginalAuthorID int64 Issue *Issue `xorm:"-"` @@ -111,7 +112,7 @@ func (r *Review) loadReviewer(e db.Engine) (err error) { if r.ReviewerID == 0 || r.Reviewer != nil { return } - r.Reviewer, err = getUserByID(e, r.ReviewerID) + r.Reviewer, err = user_model.GetUserByIDEngine(e, r.ReviewerID) return } @@ -224,7 +225,7 @@ type CreateReviewOptions struct { Content string Type ReviewType Issue *Issue - Reviewer *User + Reviewer *user_model.User ReviewerTeam *Team Official bool CommitID string @@ -232,11 +233,11 @@ type CreateReviewOptions struct { } // IsOfficialReviewer check if at least one of the provided reviewers can make official reviews in issue (counts towards required approvals) -func IsOfficialReviewer(issue *Issue, reviewers ...*User) (bool, error) { +func IsOfficialReviewer(issue *Issue, reviewers ...*user_model.User) (bool, error) { return isOfficialReviewer(db.GetEngine(db.DefaultContext), issue, reviewers...) } -func isOfficialReviewer(e db.Engine, issue *Issue, reviewers ...*User) (bool, error) { +func isOfficialReviewer(e db.Engine, issue *Issue, reviewers ...*user_model.User) (bool, error) { pr, err := getPullRequestByIssueID(e, issue.ID) if err != nil { return false, err @@ -314,7 +315,7 @@ func CreateReview(opts CreateReviewOptions) (*Review, error) { return createReview(db.GetEngine(db.DefaultContext), opts) } -func getCurrentReview(e db.Engine, reviewer *User, issue *Issue) (*Review, error) { +func getCurrentReview(e db.Engine, reviewer *user_model.User, issue *Issue) (*Review, error) { if reviewer == nil { return nil, nil } @@ -340,7 +341,7 @@ func ReviewExists(issue *Issue, treePath string, line int64) (bool, error) { } // GetCurrentReview returns the current pending review of reviewer for given issue -func GetCurrentReview(reviewer *User, issue *Issue) (*Review, error) { +func GetCurrentReview(reviewer *user_model.User, issue *Issue) (*Review, error) { return getCurrentReview(db.GetEngine(db.DefaultContext), reviewer, issue) } @@ -358,7 +359,7 @@ func IsContentEmptyErr(err error) bool { } // SubmitReview creates a review out of the existing pending review or creates a new one if no pending review exist -func SubmitReview(doer *User, issue *Issue, reviewType ReviewType, content, commitID string, stale bool, attachmentUUIDs []string) (*Review, *Comment, error) { +func SubmitReview(doer *user_model.User, issue *Issue, reviewType ReviewType, content, commitID string, stale bool, attachmentUUIDs []string) (*Review, *Comment, error) { ctx, committer, err := db.TxContext() if err != nil { return nil, nil, err @@ -627,7 +628,7 @@ func InsertReviews(reviews []*Review) error { } // AddReviewRequest add a review request from one reviewer -func AddReviewRequest(issue *Issue, reviewer, doer *User) (*Comment, error) { +func AddReviewRequest(issue *Issue, reviewer, doer *user_model.User) (*Comment, error) { ctx, committer, err := db.TxContext() if err != nil { return nil, err @@ -682,7 +683,7 @@ func AddReviewRequest(issue *Issue, reviewer, doer *User) (*Comment, error) { } // RemoveReviewRequest remove a review request from one reviewer -func RemoveReviewRequest(issue *Issue, reviewer, doer *User) (*Comment, error) { +func RemoveReviewRequest(issue *Issue, reviewer, doer *user_model.User) (*Comment, error) { ctx, committer, err := db.TxContext() if err != nil { return nil, err @@ -736,7 +737,7 @@ func RemoveReviewRequest(issue *Issue, reviewer, doer *User) (*Comment, error) { } // AddTeamReviewRequest add a review request from one team -func AddTeamReviewRequest(issue *Issue, reviewer *Team, doer *User) (*Comment, error) { +func AddTeamReviewRequest(issue *Issue, reviewer *Team, doer *user_model.User) (*Comment, error) { ctx, committer, err := db.TxContext() if err != nil { return nil, err @@ -796,7 +797,7 @@ func AddTeamReviewRequest(issue *Issue, reviewer *Team, doer *User) (*Comment, e } // RemoveTeamReviewRequest remove a review request from one team -func RemoveTeamReviewRequest(issue *Issue, reviewer *Team, doer *User) (*Comment, error) { +func RemoveTeamReviewRequest(issue *Issue, reviewer *Team, doer *user_model.User) (*Comment, error) { ctx, committer, err := db.TxContext() if err != nil { return nil, err @@ -856,7 +857,7 @@ func RemoveTeamReviewRequest(issue *Issue, reviewer *Team, doer *User) (*Comment } // MarkConversation Add or remove Conversation mark for a code comment -func MarkConversation(comment *Comment, doer *User, isResolve bool) (err error) { +func MarkConversation(comment *Comment, doer *user_model.User, isResolve bool) (err error) { if comment.Type != CommentTypeCode { return nil } @@ -884,7 +885,7 @@ func MarkConversation(comment *Comment, doer *User, isResolve bool) (err error) // CanMarkConversation Add or remove Conversation mark for a code comment permission check // the PR writer , offfcial reviewer and poster can do it -func CanMarkConversation(issue *Issue, doer *User) (permResult bool, err error) { +func CanMarkConversation(issue *Issue, doer *user_model.User) (permResult bool, err error) { if doer == nil || issue == nil { return false, fmt.Errorf("issue or doer is nil") } |