Skip to content

Commit dc78e68

Browse files
committed
feat(action): issue change title notifications
- Add `IssueChangeTitle` method to handle issue title changes - Add `notifyIssueChangeWithTitleOrContent` method to generalize notification handling for issue title or content changes - Replace hardcoded `api.HookIssueEdited` with dynamic `action` parameter in notification payloads Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent d45456b commit dc78e68

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

services/actions/notifier.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,15 @@ func (n *actionsNotifier) NewIssue(ctx context.Context, issue *issues_model.Issu
5858
// IssueChangeContent notifies change content of issue
5959
func (n *actionsNotifier) IssueChangeContent(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldContent string) {
6060
ctx = withMethod(ctx, "IssueChangeContent")
61+
n.notifyIssueChangeWithTitleOrContent(ctx, doer, issue, oldContent, api.HookIssueEdited)
62+
}
63+
64+
func (n *actionsNotifier) IssueChangeTitle(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldTitle string) {
65+
ctx = withMethod(ctx, "IssueChangeTitle")
66+
n.notifyIssueChangeWithTitleOrContent(ctx, doer, issue, oldTitle, api.HookIssueEdited)
67+
}
6168

69+
func (n *actionsNotifier) notifyIssueChangeWithTitleOrContent(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, _ string, action api.HookIssueAction) {
6270
var err error
6371
if err = issue.LoadRepo(ctx); err != nil {
6472
log.Error("LoadRepo: %v", err)
@@ -74,7 +82,7 @@ func (n *actionsNotifier) IssueChangeContent(ctx context.Context, doer *user_mod
7482
newNotifyInputFromIssue(issue, webhook_module.HookEventPullRequest).
7583
WithDoer(doer).
7684
WithPayload(&api.PullRequestPayload{
77-
Action: api.HookIssueEdited,
85+
Action: action,
7886
Index: issue.Index,
7987
PullRequest: convert.ToAPIPullRequest(ctx, issue.PullRequest, nil),
8088
Repository: convert.ToRepo(ctx, issue.Repo, access_model.Permission{AccessMode: perm_model.AccessModeNone}),
@@ -87,7 +95,7 @@ func (n *actionsNotifier) IssueChangeContent(ctx context.Context, doer *user_mod
8795
newNotifyInputFromIssue(issue, webhook_module.HookEventIssues).
8896
WithDoer(doer).
8997
WithPayload(&api.IssuePayload{
90-
Action: api.HookIssueEdited,
98+
Action: action,
9199
Index: issue.Index,
92100
Issue: convert.ToAPIIssue(ctx, doer, issue),
93101
Repository: convert.ToRepo(ctx, issue.Repo, permission),

0 commit comments

Comments
 (0)