From 0b291477cd44bcff6352fdd7bdfaa29052706566 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 18 Feb 2024 13:46:13 +0800 Subject: [PATCH 1/2] Fix missed edit issues event for actions --- services/actions/notifier.go | 45 ++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/services/actions/notifier.go b/services/actions/notifier.go index 0b4fed5db1282..ee262ac2c2700 100644 --- a/services/actions/notifier.go +++ b/services/actions/notifier.go @@ -55,6 +55,47 @@ func (n *actionsNotifier) NewIssue(ctx context.Context, issue *issues_model.Issu }).Notify(withMethod(ctx, "NewIssue")) } +// IssueChangeStatus notifies close or reopen issue to notifiers +func (n *actionsNotifier) IssueChangeContent(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldContent string) { + ctx = withMethod(ctx, "IssueChangeContent") + + var err error + if err = issue.LoadRepo(ctx); err != nil { + log.Error("LoadRepo: %v", err) + return + } + + permission, _ := access_model.GetUserRepoPermission(ctx, issue.Repo, issue.Poster) + if issue.IsPull { + if err = issue.LoadPullRequest(ctx); err != nil { + log.Error("loadPullRequest: %v", err) + return + } + newNotifyInputFromIssue(issue, webhook_module.HookEventPullRequest). + WithDoer(doer). + WithPayload(&api.PullRequestPayload{ + Action: api.HookIssueEdited, + Index: issue.Index, + PullRequest: convert.ToAPIPullRequest(ctx, issue.PullRequest, nil), + Repository: convert.ToRepo(ctx, issue.Repo, access_model.Permission{AccessMode: perm_model.AccessModeNone}), + Sender: convert.ToUser(ctx, doer, nil), + }). + WithPullRequest(issue.PullRequest). + Notify(ctx) + return + } + newNotifyInputFromIssue(issue, webhook_module.HookEventIssues). + WithDoer(doer). + WithPayload(&api.IssuePayload{ + Action: api.HookIssueEdited, + Index: issue.Index, + Issue: convert.ToAPIIssue(ctx, issue), + Repository: convert.ToRepo(ctx, issue.Repo, permission), + Sender: convert.ToUser(ctx, doer, nil), + }). + Notify(ctx) +} + // IssueChangeStatus notifies close or reopen issue to notifiers func (n *actionsNotifier) IssueChangeStatus(ctx context.Context, doer *user_model.User, commitID string, issue *issues_model.Issue, _ *issues_model.Comment, isClosed bool) { ctx = withMethod(ctx, "IssueChangeStatus") @@ -123,10 +164,6 @@ func (n *actionsNotifier) IssueChangeLabels(ctx context.Context, doer *user_mode log.Error("loadPullRequest: %v", err) return } - if err = issue.PullRequest.LoadIssue(ctx); err != nil { - log.Error("LoadIssue: %v", err) - return - } newNotifyInputFromIssue(issue, webhook_module.HookEventPullRequestLabel). WithDoer(doer). WithPayload(&api.PullRequestPayload{ From 1d772ac10b534b646f4949ba80337423afac524f Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 18 Feb 2024 13:47:57 +0800 Subject: [PATCH 2/2] Fix comment --- services/actions/notifier.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/actions/notifier.go b/services/actions/notifier.go index ee262ac2c2700..1af66ab873450 100644 --- a/services/actions/notifier.go +++ b/services/actions/notifier.go @@ -55,7 +55,7 @@ func (n *actionsNotifier) NewIssue(ctx context.Context, issue *issues_model.Issu }).Notify(withMethod(ctx, "NewIssue")) } -// IssueChangeStatus notifies close or reopen issue to notifiers +// IssueChangeContent notifies change content of issue func (n *actionsNotifier) IssueChangeContent(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldContent string) { ctx = withMethod(ctx, "IssueChangeContent")