aboutsummaryrefslogtreecommitdiffstats
path: root/services/notify/notify.go
diff options
context:
space:
mode:
Diffstat (limited to 'services/notify/notify.go')
-rw-r--r--services/notify/notify.go40
1 files changed, 38 insertions, 2 deletions
diff --git a/services/notify/notify.go b/services/notify/notify.go
index 3b5f24340b..2416cbd2e0 100644
--- a/services/notify/notify.go
+++ b/services/notify/notify.go
@@ -6,6 +6,7 @@ package notify
import (
"context"
+ actions_model "code.gitea.io/gitea/models/actions"
git_model "code.gitea.io/gitea/models/git"
issues_model "code.gitea.io/gitea/models/issues"
packages_model "code.gitea.io/gitea/models/packages"
@@ -45,10 +46,25 @@ func DeleteWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model
}
}
+func shouldSendCommentChangeNotification(ctx context.Context, comment *issues_model.Comment) bool {
+ if err := comment.LoadReview(ctx); err != nil {
+ log.Error("LoadReview: %v", err)
+ return false
+ } else if comment.Review != nil && comment.Review.Type == issues_model.ReviewTypePending {
+ // Pending review comments updating should not triggered
+ return false
+ }
+ return true
+}
+
// CreateIssueComment notifies issue comment related message to notifiers
func CreateIssueComment(ctx context.Context, doer *user_model.User, repo *repo_model.Repository,
issue *issues_model.Issue, comment *issues_model.Comment, mentions []*user_model.User,
) {
+ if !shouldSendCommentChangeNotification(ctx, comment) {
+ return
+ }
+
for _, notifier := range notifiers {
notifier.CreateIssueComment(ctx, doer, repo, issue, comment, mentions)
}
@@ -155,6 +171,10 @@ func PullReviewDismiss(ctx context.Context, doer *user_model.User, review *issue
// UpdateComment notifies update comment to notifiers
func UpdateComment(ctx context.Context, doer *user_model.User, c *issues_model.Comment, oldContent string) {
+ if !shouldSendCommentChangeNotification(ctx, c) {
+ return
+ }
+
for _, notifier := range notifiers {
notifier.UpdateComment(ctx, doer, c, oldContent)
}
@@ -162,6 +182,10 @@ func UpdateComment(ctx context.Context, doer *user_model.User, c *issues_model.C
// DeleteComment notifies delete comment to notifiers
func DeleteComment(ctx context.Context, doer *user_model.User, c *issues_model.Comment) {
+ if !shouldSendCommentChangeNotification(ctx, c) {
+ return
+ }
+
for _, notifier := range notifiers {
notifier.DeleteComment(ctx, doer, c)
}
@@ -272,9 +296,9 @@ func MigrateRepository(ctx context.Context, doer, u *user_model.User, repo *repo
}
// TransferRepository notifies create repository to notifiers
-func TransferRepository(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, newOwnerName string) {
+func TransferRepository(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, oldOwnerName string) {
for _, notifier := range notifiers {
- notifier.TransferRepository(ctx, doer, repo, newOwnerName)
+ notifier.TransferRepository(ctx, doer, repo, oldOwnerName)
}
}
@@ -374,3 +398,15 @@ func CreateCommitStatus(ctx context.Context, repo *repo_model.Repository, commit
notifier.CreateCommitStatus(ctx, repo, commit, sender, status)
}
}
+
+func WorkflowRunStatusUpdate(ctx context.Context, repo *repo_model.Repository, sender *user_model.User, run *actions_model.ActionRun) {
+ for _, notifier := range notifiers {
+ notifier.WorkflowRunStatusUpdate(ctx, repo, sender, run)
+ }
+}
+
+func WorkflowJobStatusUpdate(ctx context.Context, repo *repo_model.Repository, sender *user_model.User, job *actions_model.ActionRunJob, task *actions_model.ActionTask) {
+ for _, notifier := range notifiers {
+ notifier.WorkflowJobStatusUpdate(ctx, repo, sender, job, task)
+ }
+}