aboutsummaryrefslogtreecommitdiffstats
path: root/modules/notification
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-05-11 18:09:36 +0800
committerGitHub <noreply@github.com>2022-05-11 12:09:36 +0200
commitcbd45471b1100bffcd2f18719b56a5da5468756b (patch)
tree11fcb818fd4e9d7b6bdb97d1b5bfbe2ed3df5747 /modules/notification
parent8e8e936adacea873013b89d534f60207e67f2b05 (diff)
downloadgitea-cbd45471b1100bffcd2f18719b56a5da5468756b.tar.gz
gitea-cbd45471b1100bffcd2f18719b56a5da5468756b.zip
Move access and repo permission to models/perm/access (#19350)
* Move access and repo permission to models/perm/access * Remove unnecessary code
Diffstat (limited to 'modules/notification')
-rw-r--r--modules/notification/webhook/webhook.go39
1 files changed, 20 insertions, 19 deletions
diff --git a/modules/notification/webhook/webhook.go b/modules/notification/webhook/webhook.go
index c59e972ed6..38077f2180 100644
--- a/modules/notification/webhook/webhook.go
+++ b/modules/notification/webhook/webhook.go
@@ -11,6 +11,7 @@ import (
"code.gitea.io/gitea/models/db"
packages_model "code.gitea.io/gitea/models/packages"
"code.gitea.io/gitea/models/perm"
+ access_model "code.gitea.io/gitea/models/perm/access"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unit"
user_model "code.gitea.io/gitea/models/user"
@@ -52,7 +53,7 @@ func (m *webhookNotifier) NotifyIssueClearLabels(doer *user_model.User, issue *m
return
}
- mode, _ := models.AccessLevel(issue.Poster, issue.Repo)
+ mode, _ := access_model.AccessLevel(issue.Poster, issue.Repo)
var err error
if issue.IsPull {
if err = issue.LoadPullRequest(); err != nil {
@@ -82,8 +83,8 @@ func (m *webhookNotifier) NotifyIssueClearLabels(doer *user_model.User, issue *m
}
func (m *webhookNotifier) NotifyForkRepository(doer *user_model.User, oldRepo, repo *repo_model.Repository) {
- oldMode, _ := models.AccessLevel(doer, oldRepo)
- mode, _ := models.AccessLevel(doer, repo)
+ oldMode, _ := access_model.AccessLevel(doer, oldRepo)
+ mode, _ := access_model.AccessLevel(doer, repo)
// forked webhook
if err := webhook_services.PrepareWebhooks(oldRepo, webhook.HookEventFork, &api.ForkPayload{
@@ -151,7 +152,7 @@ func (m *webhookNotifier) NotifyIssueChangeAssignee(doer *user_model.User, issue
defer finished()
if issue.IsPull {
- mode, _ := models.AccessLevelUnit(doer, issue.Repo, unit.TypePullRequests)
+ mode, _ := access_model.AccessLevelUnit(doer, issue.Repo, unit.TypePullRequests)
if err := issue.LoadPullRequest(); err != nil {
log.Error("LoadPullRequest failed: %v", err)
@@ -175,7 +176,7 @@ func (m *webhookNotifier) NotifyIssueChangeAssignee(doer *user_model.User, issue
return
}
} else {
- mode, _ := models.AccessLevelUnit(doer, issue.Repo, unit.TypeIssues)
+ mode, _ := access_model.AccessLevelUnit(doer, issue.Repo, unit.TypeIssues)
apiIssue := &api.IssuePayload{
Index: issue.Index,
Issue: convert.ToAPIIssue(issue),
@@ -199,7 +200,7 @@ func (m *webhookNotifier) NotifyIssueChangeTitle(doer *user_model.User, issue *m
ctx, _, finished := process.GetManager().AddContext(graceful.GetManager().HammerContext(), fmt.Sprintf("webhook.NotifyIssueChangeTitle User: %s[%d] Issue[%d] #%d in [%d]", doer.Name, doer.ID, issue.ID, issue.Index, issue.RepoID))
defer finished()
- mode, _ := models.AccessLevel(issue.Poster, issue.Repo)
+ mode, _ := access_model.AccessLevel(issue.Poster, issue.Repo)
var err error
if issue.IsPull {
if err = issue.LoadPullRequest(); err != nil {
@@ -243,7 +244,7 @@ func (m *webhookNotifier) NotifyIssueChangeStatus(doer *user_model.User, issue *
ctx, _, finished := process.GetManager().AddContext(graceful.GetManager().HammerContext(), fmt.Sprintf("webhook.NotifyIssueChangeStatus User: %s[%d] Issue[%d] #%d in [%d]", doer.Name, doer.ID, issue.ID, issue.Index, issue.RepoID))
defer finished()
- mode, _ := models.AccessLevel(issue.Poster, issue.Repo)
+ mode, _ := access_model.AccessLevel(issue.Poster, issue.Repo)
var err error
if issue.IsPull {
if err = issue.LoadPullRequest(); err != nil {
@@ -292,7 +293,7 @@ func (m *webhookNotifier) NotifyNewIssue(issue *models.Issue, mentions []*user_m
return
}
- mode, _ := models.AccessLevel(issue.Poster, issue.Repo)
+ mode, _ := access_model.AccessLevel(issue.Poster, issue.Repo)
if err := webhook_services.PrepareWebhooks(issue.Repo, webhook.HookEventIssues, &api.IssuePayload{
Action: api.HookIssueOpened,
Index: issue.Index,
@@ -321,7 +322,7 @@ func (m *webhookNotifier) NotifyNewPullRequest(pull *models.PullRequest, mention
return
}
- mode, _ := models.AccessLevel(pull.Issue.Poster, pull.Issue.Repo)
+ mode, _ := access_model.AccessLevel(pull.Issue.Poster, pull.Issue.Repo)
if err := webhook_services.PrepareWebhooks(pull.Issue.Repo, webhook.HookEventPullRequest, &api.PullRequestPayload{
Action: api.HookIssueOpened,
Index: pull.Issue.Index,
@@ -337,7 +338,7 @@ func (m *webhookNotifier) NotifyIssueChangeContent(doer *user_model.User, issue
ctx, _, finished := process.GetManager().AddContext(graceful.GetManager().HammerContext(), fmt.Sprintf("webhook.NotifyIssueChangeContent User: %s[%d] Issue[%d] #%d in [%d]", doer.Name, doer.ID, issue.ID, issue.Index, issue.RepoID))
defer finished()
- mode, _ := models.AccessLevel(issue.Poster, issue.Repo)
+ mode, _ := access_model.AccessLevel(issue.Poster, issue.Repo)
var err error
if issue.IsPull {
issue.PullRequest.Issue = issue
@@ -389,7 +390,7 @@ func (m *webhookNotifier) NotifyUpdateComment(doer *user_model.User, c *models.C
return
}
- mode, _ := models.AccessLevel(doer, c.Issue.Repo)
+ mode, _ := access_model.AccessLevel(doer, c.Issue.Repo)
if c.Issue.IsPull {
err = webhook_services.PrepareWebhooks(c.Issue.Repo, webhook.HookEventPullRequestComment, &api.IssueCommentPayload{
Action: api.HookIssueCommentEdited,
@@ -428,7 +429,7 @@ func (m *webhookNotifier) NotifyUpdateComment(doer *user_model.User, c *models.C
func (m *webhookNotifier) NotifyCreateIssueComment(doer *user_model.User, repo *repo_model.Repository,
issue *models.Issue, comment *models.Comment, mentions []*user_model.User,
) {
- mode, _ := models.AccessLevel(doer, repo)
+ mode, _ := access_model.AccessLevel(doer, repo)
var err error
if issue.IsPull {
@@ -473,7 +474,7 @@ func (m *webhookNotifier) NotifyDeleteComment(doer *user_model.User, comment *mo
return
}
- mode, _ := models.AccessLevel(doer, comment.Issue.Repo)
+ mode, _ := access_model.AccessLevel(doer, comment.Issue.Repo)
if comment.Issue.IsPull {
err = webhook_services.PrepareWebhooks(comment.Issue.Repo, webhook.HookEventPullRequestComment, &api.IssueCommentPayload{
@@ -518,7 +519,7 @@ func (m *webhookNotifier) NotifyIssueChangeLabels(doer *user_model.User, issue *
return
}
- mode, _ := models.AccessLevel(issue.Poster, issue.Repo)
+ mode, _ := access_model.AccessLevel(issue.Poster, issue.Repo)
if issue.IsPull {
if err = issue.LoadPullRequest(); err != nil {
log.Error("loadPullRequest: %v", err)
@@ -566,7 +567,7 @@ func (m *webhookNotifier) NotifyIssueChangeMilestone(doer *user_model.User, issu
return
}
- mode, _ := models.AccessLevel(doer, issue.Repo)
+ mode, _ := access_model.AccessLevel(doer, issue.Repo)
if issue.IsPull {
err = issue.PullRequest.LoadIssue()
if err != nil {
@@ -640,7 +641,7 @@ func (*webhookNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *use
return
}
- mode, err := models.AccessLevel(doer, pr.Issue.Repo)
+ mode, err := access_model.AccessLevel(doer, pr.Issue.Repo)
if err != nil {
log.Error("models.AccessLevel: %v", err)
return
@@ -676,7 +677,7 @@ func (m *webhookNotifier) NotifyPullRequestChangeTargetBranch(doer *user_model.U
return
}
issue.PullRequest.Issue = issue
- mode, _ := models.AccessLevel(issue.Poster, issue.Repo)
+ mode, _ := access_model.AccessLevel(issue.Poster, issue.Repo)
err = webhook_services.PrepareWebhooks(issue.Repo, webhook.HookEventPullRequest, &api.PullRequestPayload{
Action: api.HookIssueEdited,
Index: issue.Index,
@@ -719,7 +720,7 @@ func (m *webhookNotifier) NotifyPullRequestReview(pr *models.PullRequest, review
return
}
- mode, err := models.AccessLevel(review.Issue.Poster, review.Issue.Repo)
+ mode, err := access_model.AccessLevel(review.Issue.Poster, review.Issue.Repo)
if err != nil {
log.Error("models.AccessLevel: %v", err)
return
@@ -801,7 +802,7 @@ func sendReleaseHook(doer *user_model.User, rel *models.Release, action api.Hook
return
}
- mode, _ := models.AccessLevel(doer, rel.Repo)
+ mode, _ := access_model.AccessLevel(doer, rel.Repo)
if err := webhook_services.PrepareWebhooks(rel.Repo, webhook.HookEventRelease, &api.ReleasePayload{
Action: action,
Release: convert.ToRelease(rel),