diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2023-09-06 02:37:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-05 18:37:47 +0000 |
commit | 540bf9fa6d0d86297c9d575640798b718767bd9f (patch) | |
tree | 4b4a782b71e6f066af6c7807337745dc5ee6899a /services/pull | |
parent | 084eacb5d42f1ed2520442a4bbc91bb70c9759e1 (diff) | |
download | gitea-540bf9fa6d0d86297c9d575640798b718767bd9f.tar.gz gitea-540bf9fa6d0d86297c9d575640798b718767bd9f.zip |
Move notification interface to services layer (#26915)
Extract from #22266
Diffstat (limited to 'services/pull')
-rw-r--r-- | services/pull/check.go | 4 | ||||
-rw-r--r-- | services/pull/merge.go | 8 | ||||
-rw-r--r-- | services/pull/pull.go | 14 | ||||
-rw-r--r-- | services/pull/review.go | 12 |
4 files changed, 19 insertions, 19 deletions
diff --git a/services/pull/check.go b/services/pull/check.go index ec898201bb..dcb488c309 100644 --- a/services/pull/check.go +++ b/services/pull/check.go @@ -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 diff --git a/services/pull/merge.go b/services/pull/merge.go index 7051fd9eda..185060cbac 100644 --- a/services/pull/merge.go +++ b/services/pull/merge.go @@ -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 } diff --git a/services/pull/pull.go b/services/pull/pull.go index d4352abafe..8e57aebe3d 100644 --- a/services/pull/pull.go +++ b/services/pull/pull.go @@ -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) } } } diff --git a/services/pull/review.go b/services/pull/review.go index 6e088382f9..c82d1341b6 100644 --- a/services/pull/review.go +++ b/services/pull/review.go @@ -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 } |