forked from
tangled.org/core
Monorepo for Tangled — https://tangled.org
1package indexer
2
3import (
4 "context"
5
6 "github.com/bluesky-social/indigo/atproto/syntax"
7 "tangled.org/core/appview/models"
8 "tangled.org/core/appview/notify"
9 "tangled.org/core/log"
10)
11
12var _ notify.Notifier = &Indexer{}
13
14func (ix *Indexer) NewIssue(ctx context.Context, issue *models.Issue, mentions []syntax.DID) {
15 l := log.FromContext(ctx).With("notifier", "indexer", "issue", issue)
16 l.Debug("indexing new issue")
17 err := ix.Issues.Index(ctx, *issue)
18 if err != nil {
19 l.Error("failed to index an issue", "err", err)
20 }
21}
22
23func (ix *Indexer) NewIssueState(ctx context.Context, actor syntax.DID, issue *models.Issue) {
24 l := log.FromContext(ctx).With("notifier", "indexer", "issue", issue)
25 l.Debug("updating an issue")
26 err := ix.Issues.Index(ctx, *issue)
27 if err != nil {
28 l.Error("failed to index an issue", "err", err)
29 }
30}
31
32func (ix *Indexer) DeleteIssue(ctx context.Context, issue *models.Issue) {
33 l := log.FromContext(ctx).With("notifier", "indexer", "issue", issue)
34 l.Debug("deleting an issue")
35 err := ix.Issues.Delete(ctx, issue.Id)
36 if err != nil {
37 l.Error("failed to delete an issue", "err", err)
38 }
39}
40
41func (ix *Indexer) NewPull(ctx context.Context, pull *models.Pull) {
42 l := log.FromContext(ctx).With("notifier", "indexer", "pull", pull)
43 l.Debug("indexing new pr")
44 err := ix.Pulls.Index(ctx, pull)
45 if err != nil {
46 l.Error("failed to index a pr", "err", err)
47 }
48}
49
50func (ix *Indexer) NewPullState(ctx context.Context, actor syntax.DID, pull *models.Pull) {
51 l := log.FromContext(ctx).With("notifier", "indexer", "pull", pull)
52 l.Debug("updating a pr")
53 err := ix.Pulls.Index(ctx, pull)
54 if err != nil {
55 l.Error("failed to index a pr", "err", err)
56 }
57}