From b2857c26f0d3d0ceb15dc3eed1f82f8d31199e07 Mon Sep 17 00:00:00 2001 From: Anirudh Oppiliappan Date: Mon, 15 Sep 2025 16:58:47 +0300 Subject: [PATCH] appview/{pulls,issues}: more notifications Change-Id: pyonqyyrupplyklpqkxrommuvkputyxu Signed-off-by: Anirudh Oppiliappan --- appview/issues/issues.go | 8 ++++++++ appview/notify/merged_notifier.go | 12 ++++++++++++ appview/notify/notifier.go | 4 ++++ appview/pulls/pulls.go | 9 +++++++++ 4 files changed, 33 insertions(+) diff --git a/appview/issues/issues.go b/appview/issues/issues.go index 87c301e3..88984e44 100644 --- a/appview/issues/issues.go +++ b/appview/issues/issues.go @@ -301,6 +301,9 @@ func (rp *Issues) CloseIssue(w http.ResponseWriter, r *http.Request) { return } + // notify about the issue closure + rp.notifier.NewIssueClosed(r.Context(), issue) + rp.pages.HxLocation(w, fmt.Sprintf("/%s/issues/%d", f.OwnerSlashRepo(), issue.IssueId)) return } else { @@ -434,6 +437,11 @@ func (rp *Issues) NewIssueComment(w http.ResponseWriter, r *http.Request) { // reset atUri to make rollback a no-op atUri = "" + + // notify about the new comment + comment.Id = commentId + rp.notifier.NewIssueComment(r.Context(), &comment) + rp.pages.HxLocation(w, fmt.Sprintf("/%s/issues/%d#comment-%d", f.OwnerSlashRepo(), issue.IssueId, commentId)) } diff --git a/appview/notify/merged_notifier.go b/appview/notify/merged_notifier.go index 4b880dfb..195f44bb 100644 --- a/appview/notify/merged_notifier.go +++ b/appview/notify/merged_notifier.go @@ -72,6 +72,18 @@ func (m *mergedNotifier) NewPullComment(ctx context.Context, comment *models.Pul } } +func (m *mergedNotifier) NewPullMerged(ctx context.Context, pull *models.Pull) { + for _, notifier := range m.notifiers { + notifier.NewPullMerged(ctx, pull) + } +} + +func (m *mergedNotifier) NewPullClosed(ctx context.Context, pull *models.Pull) { + for _, notifier := range m.notifiers { + notifier.NewPullClosed(ctx, pull) + } +} + func (m *mergedNotifier) UpdateProfile(ctx context.Context, profile *models.Profile) { for _, notifier := range m.notifiers { notifier.UpdateProfile(ctx, profile) diff --git a/appview/notify/notifier.go b/appview/notify/notifier.go index 83ae2c76..84efcf36 100644 --- a/appview/notify/notifier.go +++ b/appview/notify/notifier.go @@ -21,6 +21,8 @@ type Notifier interface { NewPull(ctx context.Context, pull *models.Pull) NewPullComment(ctx context.Context, comment *models.PullComment) + NewPullMerged(ctx context.Context, pull *models.Pull) + NewPullClosed(ctx context.Context, pull *models.Pull) UpdateProfile(ctx context.Context, profile *models.Profile) @@ -48,6 +50,8 @@ func (m *BaseNotifier) DeleteFollow(ctx context.Context, follow *models.Follow) func (m *BaseNotifier) NewPull(ctx context.Context, pull *models.Pull) {} func (m *BaseNotifier) NewPullComment(ctx context.Context, models *models.PullComment) {} +func (m *BaseNotifier) NewPullMerged(ctx context.Context, pull *models.Pull) {} +func (m *BaseNotifier) NewPullClosed(ctx context.Context, pull *models.Pull) {} func (m *BaseNotifier) UpdateProfile(ctx context.Context, profile *models.Profile) {} diff --git a/appview/pulls/pulls.go b/appview/pulls/pulls.go index 72b5c3f0..77f35577 100644 --- a/appview/pulls/pulls.go +++ b/appview/pulls/pulls.go @@ -2147,6 +2147,11 @@ func (s *Pulls) MergePull(w http.ResponseWriter, r *http.Request) { return } + // notify about the pull merge + for _, p := range pullsToMerge { + s.notifier.NewPullMerged(r.Context(), p) + } + s.pages.HxLocation(w, fmt.Sprintf("/@%s/%s/pulls/%d", f.OwnerHandle(), f.Name, pull.PullId)) } @@ -2214,6 +2219,10 @@ func (s *Pulls) ClosePull(w http.ResponseWriter, r *http.Request) { return } + for _, p := range pullsToClose { + s.notifier.NewPullClosed(r.Context(), p) + } + s.pages.HxLocation(w, fmt.Sprintf("/%s/pulls/%d", f.OwnerSlashRepo(), pull.PullId)) } -- 2.43.0