From 2799032e6174d9d8c443568b3abc572d57a952dc Mon Sep 17 00:00:00 2001 From: Seongmin Lee Date: Wed, 22 Oct 2025 03:54:05 +0900 Subject: [PATCH] appview/notify: add `DeleteIssue` event Change-Id: lrzmvpkzwwrvkktrxwtsxtuwuqzzmqmx Signed-off-by: Seongmin Lee --- appview/indexer/issues/indexer.go | 4 ++++ appview/indexer/notifier.go | 9 +++++++++ appview/issues/issues.go | 2 ++ appview/notify/db/db.go | 4 ++++ appview/notify/merged_notifier.go | 4 ++++ appview/notify/notifier.go | 2 ++ 6 files changed, 25 insertions(+) diff --git a/appview/indexer/issues/indexer.go b/appview/indexer/issues/indexer.go index 20524b41..d652e72a 100644 --- a/appview/indexer/issues/indexer.go +++ b/appview/indexer/issues/indexer.go @@ -216,6 +216,10 @@ func (ix *Indexer) Index(ctx context.Context, issues ...models.Issue) error { return batch.Flush() } +func (ix *Indexer) Delete(ctx context.Context, issueId int64) error { + return ix.indexer.Delete(base36.Encode(issueId)) +} + // Search searches for issues func (ix *Indexer) Search(ctx context.Context, opts models.IssueSearchOptions) (*SearchResult, error) { var queries []query.Query diff --git a/appview/indexer/notifier.go b/appview/indexer/notifier.go index f862ac73..61012c92 100644 --- a/appview/indexer/notifier.go +++ b/appview/indexer/notifier.go @@ -18,3 +18,12 @@ func (ix *Indexer) NewIssue(ctx context.Context, issue *models.Issue) { 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") + err := ix.Issues.Delete(ctx, issue.Id) + if err != nil { + l.Error("failed to delete an issue", "err", err) + } +} diff --git a/appview/issues/issues.go b/appview/issues/issues.go index 42783ff9..51dabc6d 100644 --- a/appview/issues/issues.go +++ b/appview/issues/issues.go @@ -263,6 +263,8 @@ func (rp *Issues) DeleteIssue(w http.ResponseWriter, r *http.Request) { return } + rp.notifier.DeleteIssue(r.Context(), issue) + // return to all issues page rp.pages.HxRedirect(w, "/"+f.RepoInfo(user).FullName()+"/issues") } diff --git a/appview/notify/db/db.go b/appview/notify/db/db.go index 6224ad17..62efc857 100644 --- a/appview/notify/db/db.go +++ b/appview/notify/db/db.go @@ -151,6 +151,10 @@ func (n *databaseNotifier) NewIssueComment(ctx context.Context, comment *models. ) } +func (n *databaseNotifier) DeleteIssue(ctx context.Context, issue *models.Issue) { + // no-op for now +} + func (n *databaseNotifier) NewFollow(ctx context.Context, follow *models.Follow) { actorDid := syntax.DID(follow.UserDid) recipients := []syntax.DID{syntax.DID(follow.SubjectDid)} diff --git a/appview/notify/merged_notifier.go b/appview/notify/merged_notifier.go index acec12d1..2e15e4d3 100644 --- a/appview/notify/merged_notifier.go +++ b/appview/notify/merged_notifier.go @@ -60,6 +60,10 @@ func (m *mergedNotifier) NewIssueClosed(ctx context.Context, issue *models.Issue m.fanout("NewIssueClosed", ctx, issue) } +func (m *mergedNotifier) DeleteIssue(ctx context.Context, issue *models.Issue) { + m.fanout("DeleteIssue", ctx, issue) +} + func (m *mergedNotifier) NewFollow(ctx context.Context, follow *models.Follow) { m.fanout("NewFollow", ctx, follow) } diff --git a/appview/notify/notifier.go b/appview/notify/notifier.go index 84efcf36..a319c05d 100644 --- a/appview/notify/notifier.go +++ b/appview/notify/notifier.go @@ -15,6 +15,7 @@ type Notifier interface { NewIssue(ctx context.Context, issue *models.Issue) NewIssueComment(ctx context.Context, comment *models.IssueComment) NewIssueClosed(ctx context.Context, issue *models.Issue) + DeleteIssue(ctx context.Context, issue *models.Issue) NewFollow(ctx context.Context, follow *models.Follow) DeleteFollow(ctx context.Context, follow *models.Follow) @@ -44,6 +45,7 @@ func (m *BaseNotifier) DeleteStar(ctx context.Context, star *models.Star) {} func (m *BaseNotifier) NewIssue(ctx context.Context, issue *models.Issue) {} func (m *BaseNotifier) NewIssueComment(ctx context.Context, comment *models.IssueComment) {} func (m *BaseNotifier) NewIssueClosed(ctx context.Context, issue *models.Issue) {} +func (m *BaseNotifier) DeleteIssue(ctx context.Context, issue *models.Issue) {} func (m *BaseNotifier) NewFollow(ctx context.Context, follow *models.Follow) {} func (m *BaseNotifier) DeleteFollow(ctx context.Context, follow *models.Follow) {} -- 2.43.0