mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Move notification interface to services layer (#26915)
Extract from #22266
This commit is contained in:
@@ -22,11 +22,11 @@ import (
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/graceful"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/notification"
|
||||
"code.gitea.io/gitea/modules/process"
|
||||
"code.gitea.io/gitea/modules/queue"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
asymkey_service "code.gitea.io/gitea/services/asymkey"
|
||||
notify_service "code.gitea.io/gitea/services/notify"
|
||||
)
|
||||
|
||||
// prPatchCheckerQueue represents a queue to handle update pull request tests
|
||||
@@ -295,7 +295,7 @@ func manuallyMerged(ctx context.Context, pr *issues_model.PullRequest) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
notification.NotifyMergePullRequest(ctx, merger, pr)
|
||||
notify_service.MergePullRequest(ctx, merger, pr)
|
||||
|
||||
log.Info("manuallyMerged[%-v]: Marked as manually merged into %s/%s by commit id: %s", pr, pr.BaseRepo.Name, pr.BaseBranch, commit.ID.String())
|
||||
return true
|
||||
|
@@ -25,12 +25,12 @@ import (
|
||||
"code.gitea.io/gitea/modules/cache"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/notification"
|
||||
"code.gitea.io/gitea/modules/references"
|
||||
repo_module "code.gitea.io/gitea/modules/repository"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
issue_service "code.gitea.io/gitea/services/issue"
|
||||
notify_service "code.gitea.io/gitea/services/notify"
|
||||
)
|
||||
|
||||
// getMergeMessage composes the message used when merging a pull request.
|
||||
@@ -206,9 +206,9 @@ func Merge(ctx context.Context, pr *issues_model.PullRequest, doer *user_model.U
|
||||
}
|
||||
|
||||
if wasAutoMerged {
|
||||
notification.NotifyAutoMergePullRequest(ctx, doer, pr)
|
||||
notify_service.AutoMergePullRequest(ctx, doer, pr)
|
||||
} else {
|
||||
notification.NotifyMergePullRequest(ctx, doer, pr)
|
||||
notify_service.MergePullRequest(ctx, doer, pr)
|
||||
}
|
||||
|
||||
// Reset cached commit count
|
||||
@@ -521,7 +521,7 @@ func MergedManually(pr *issues_model.PullRequest, doer *user_model.User, baseGit
|
||||
return err
|
||||
}
|
||||
|
||||
notification.NotifyMergePullRequest(baseGitRepo.Ctx, doer, pr)
|
||||
notify_service.MergePullRequest(baseGitRepo.Ctx, doer, pr)
|
||||
log.Info("manuallyMerged[%d]: Marked as manually merged into %s/%s by commit id: %s", pr.ID, pr.BaseRepo.Name, pr.BaseBranch, commitID)
|
||||
return nil
|
||||
}
|
||||
|
@@ -25,12 +25,12 @@ import (
|
||||
"code.gitea.io/gitea/modules/graceful"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/notification"
|
||||
repo_module "code.gitea.io/gitea/modules/repository"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/sync"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
issue_service "code.gitea.io/gitea/services/issue"
|
||||
notify_service "code.gitea.io/gitea/services/notify"
|
||||
)
|
||||
|
||||
// TODO: use clustered lock (unique queue? or *abuse* cache)
|
||||
@@ -145,12 +145,12 @@ func NewPullRequest(ctx context.Context, repo *repo_model.Repository, issue *iss
|
||||
return err
|
||||
}
|
||||
|
||||
notification.NotifyNewPullRequest(ctx, pr, mentions)
|
||||
notify_service.NewPullRequest(ctx, pr, mentions)
|
||||
if len(issue.Labels) > 0 {
|
||||
notification.NotifyIssueChangeLabels(ctx, issue.Poster, issue, issue.Labels, nil)
|
||||
notify_service.IssueChangeLabels(ctx, issue.Poster, issue, issue.Labels, nil)
|
||||
}
|
||||
if issue.Milestone != nil {
|
||||
notification.NotifyIssueChangeMilestone(ctx, issue.Poster, issue, 0)
|
||||
notify_service.IssueChangeMilestone(ctx, issue.Poster, issue, 0)
|
||||
}
|
||||
if len(assigneeIDs) > 0 {
|
||||
for _, assigneeID := range assigneeIDs {
|
||||
@@ -158,7 +158,7 @@ func NewPullRequest(ctx context.Context, repo *repo_model.Repository, issue *iss
|
||||
if err != nil {
|
||||
return ErrDependenciesLeft
|
||||
}
|
||||
notification.NotifyIssueChangeAssignee(ctx, issue.Poster, issue, assignee, false, assigneeCommentMap[assigneeID])
|
||||
notify_service.IssueChangeAssignee(ctx, issue.Poster, issue, assignee, false, assigneeCommentMap[assigneeID])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,7 +315,7 @@ func AddTestPullRequestTask(doer *user_model.User, repoID int64, branch string,
|
||||
AddToTaskQueue(ctx, pr)
|
||||
comment, err := CreatePushPullComment(ctx, doer, pr, oldCommitID, newCommitID)
|
||||
if err == nil && comment != nil {
|
||||
notification.NotifyPullRequestPushCommits(ctx, doer, pr, comment)
|
||||
notify_service.PullRequestPushCommits(ctx, doer, pr, comment)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -365,7 +365,7 @@ func AddTestPullRequestTask(doer *user_model.User, repoID int64, branch string,
|
||||
}
|
||||
}
|
||||
|
||||
notification.NotifyPullRequestSynchronized(ctx, doer, pr)
|
||||
notify_service.PullRequestSynchronized(ctx, doer, pr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -17,9 +17,9 @@ import (
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/notification"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
notify_service "code.gitea.io/gitea/services/notify"
|
||||
)
|
||||
|
||||
var notEnoughLines = regexp.MustCompile(`fatal: file .* has only \d+ lines?`)
|
||||
@@ -113,7 +113,7 @@ func CreateCodeComment(ctx context.Context, doer *user_model.User, gitRepo *git.
|
||||
return nil, err
|
||||
}
|
||||
|
||||
notification.NotifyCreateIssueComment(ctx, doer, issue.Repo, issue, comment, mentions)
|
||||
notify_service.CreateIssueComment(ctx, doer, issue.Repo, issue, comment, mentions)
|
||||
|
||||
return comment, nil
|
||||
}
|
||||
@@ -298,7 +298,7 @@ func SubmitReview(ctx context.Context, doer *user_model.User, gitRepo *git.Repos
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
notification.NotifyPullRequestReview(ctx, pr, review, comm, mentions)
|
||||
notify_service.PullRequestReview(ctx, pr, review, comm, mentions)
|
||||
|
||||
for _, lines := range review.CodeComments {
|
||||
for _, comments := range lines {
|
||||
@@ -307,7 +307,7 @@ func SubmitReview(ctx context.Context, doer *user_model.User, gitRepo *git.Repos
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
notification.NotifyPullRequestCodeComment(ctx, pr, codeComment, mentions)
|
||||
notify_service.PullRequestCodeComment(ctx, pr, codeComment, mentions)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -355,7 +355,7 @@ func DismissApprovalReviews(ctx context.Context, doer *user_model.User, pull *is
|
||||
comment.Poster = doer
|
||||
comment.Issue = review.Issue
|
||||
|
||||
notification.NotifyPullReviewDismiss(ctx, doer, review, comment)
|
||||
notify_service.PullReviewDismiss(ctx, doer, review, comment)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
@@ -426,7 +426,7 @@ func DismissReview(ctx context.Context, reviewID, repoID int64, message string,
|
||||
comment.Poster = doer
|
||||
comment.Issue = review.Issue
|
||||
|
||||
notification.NotifyPullReviewDismiss(ctx, doer, review, comment)
|
||||
notify_service.PullReviewDismiss(ctx, doer, review, comment)
|
||||
|
||||
return comment, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user