appview/indexer: handle NewIssueClosed #695

merged
opened by boltless.me targeting master from boltless.me/core: feat/search

Doesn't suport issue reopen yet

Signed-off-by: Seongmin Lee git@boltless.me

Changed files
+17
appview
indexer
issues
+9
appview/indexer/notifier.go
···
}
}
+
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")
+8
appview/issues/issues.go
···
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)
···
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 {