aboutsummaryrefslogtreecommitdiffstats
path: root/services/pull
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-06-30 23:55:08 +0800
committerGitHub <noreply@github.com>2022-06-30 23:55:08 +0800
commit184a7d4195baffb169f24f4e9a4524f8d4045e91 (patch)
treeb7d620626be91e789115d41d9829518e4119c4a1 /services/pull
parentdb3355cb1aa206fc9f1cf786543607204f628218 (diff)
downloadgitea-184a7d4195baffb169f24f4e9a4524f8d4045e91.tar.gz
gitea-184a7d4195baffb169f24f4e9a4524f8d4045e91.zip
Check if project has the same repository id with issue when assign project to issue (#20133)
* Check if project has the same repository id with issue when assign project to issue * Check if issue's repository id match project's repository id * Add more permission checking * Remove invalid argument * Fix errors * Add generic check * Remove duplicated check * Return error + add check for new issues * Apply suggestions from code review Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: Gusted <williamzijl7@hotmail.com> Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'services/pull')
-rw-r--r--services/pull/review.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/services/pull/review.go b/services/pull/review.go
index 6bb8877b0f..22e0ae9853 100644
--- a/services/pull/review.go
+++ b/services/pull/review.go
@@ -271,7 +271,7 @@ func SubmitReview(ctx context.Context, doer *user_model.User, gitRepo *git.Repos
}
// DismissReview dismissing stale review by repo admin
-func DismissReview(ctx context.Context, reviewID int64, message string, doer *user_model.User, isDismiss bool) (comment *issues_model.Comment, err error) {
+func DismissReview(ctx context.Context, reviewID, repoID int64, message string, doer *user_model.User, isDismiss bool) (comment *issues_model.Comment, err error) {
review, err := issues_model.GetReviewByID(ctx, reviewID)
if err != nil {
return
@@ -281,6 +281,16 @@ func DismissReview(ctx context.Context, reviewID int64, message string, doer *us
return nil, fmt.Errorf("not need to dismiss this review because it's type is not Approve or change request")
}
+ // load data for notify
+ if err = review.LoadAttributes(ctx); err != nil {
+ return nil, err
+ }
+
+ // Check if the review's repoID is the one we're currently expecting.
+ if review.Issue.RepoID != repoID {
+ return nil, fmt.Errorf("reviews's repository is not the same as the one we expect")
+ }
+
if err = issues_model.DismissReview(review, isDismiss); err != nil {
return
}
@@ -289,10 +299,6 @@ func DismissReview(ctx context.Context, reviewID int64, message string, doer *us
return nil, nil
}
- // load data for notify
- if err = review.LoadAttributes(ctx); err != nil {
- return
- }
if err = review.Issue.LoadPullRequest(); err != nil {
return
}