From 98a4964a3ce2b2d9e3a4a89a647109482931cc8b Mon Sep 17 00:00:00 2001 From: Seongmin Lee Date: Wed, 22 Oct 2025 04:44:48 +0900 Subject: [PATCH] appview/indexer: handle `NewIssueClosed` Change-Id: qvnkuurwovnqrnsvztwqonrlsqypmwzp Doesn't suport issue reopen yet Signed-off-by: Seongmin Lee --- appview/indexer/notifier.go | 9 +++++++++ appview/issues/issues.go | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/appview/indexer/notifier.go b/appview/indexer/notifier.go index 61012c92..c7bd3aab 100644 --- a/appview/indexer/notifier.go +++ b/appview/indexer/notifier.go @@ -19,6 +19,15 @@ func (ix *Indexer) NewIssue(ctx context.Context, issue *models.Issue) { } } +func (ix *Indexer) NewIssueClosed(ctx context.Context, issue *models.Issue) { + l := log.FromContext(ctx).With("notifier", "indexer.NewIssueClosed", "issue", issue) + l.Debug("updating an issue") + err := ix.Issues.Index(ctx, *issue) + if err != nil { + l.Error("failed to index an issue", "err", err) + } +} + func (ix *Indexer) DeleteIssue(ctx context.Context, issue *models.Issue) { l := log.FromContext(ctx).With("notifier", "indexer.DeleteIssue", "issue", issue) l.Debug("deleting an issue") diff --git a/appview/issues/issues.go b/appview/issues/issues.go index 49008209..791903b6 100644 --- a/appview/issues/issues.go +++ b/appview/issues/issues.go @@ -305,6 +305,8 @@ func (rp *Issues) CloseIssue(w http.ResponseWriter, r *http.Request) { rp.pages.Notice(w, "issue-action", "Failed to close issue. Try again later.") return } + // change the issue state (this will pass down to the notifiers) + issue.Open = false // notify about the issue closure rp.notifier.NewIssueClosed(r.Context(), issue) @@ -353,6 +355,12 @@ func (rp *Issues) ReopenIssue(w http.ResponseWriter, r *http.Request) { rp.pages.Notice(w, "issue-action", "Failed to reopen issue. Try again later.") return } + // change the issue state (this will pass down to the notifiers) + issue.Open = true + + // // notify about the issue reopen + // rp.notifier.NewIssueReopen(r.Context(), issue) + rp.pages.HxLocation(w, fmt.Sprintf("/%s/issues/%d", f.OwnerSlashRepo(), issue.IssueId)) return } else { -- 2.43.0