Monorepo for Tangled
1package notify
2
3import (
4 "context"
5 "log/slog"
6
7 "tangled.org/core/appview/models"
8 tlog "tangled.org/core/log"
9
10 "github.com/bluesky-social/indigo/atproto/syntax"
11)
12
13type loggingNotifier struct {
14 inner Notifier
15 logger *slog.Logger
16}
17
18func NewLoggingNotifier(inner Notifier, logger *slog.Logger) Notifier {
19 return &loggingNotifier{
20 inner,
21 logger,
22 }
23}
24
25var _ Notifier = &loggingNotifier{}
26
27func (l *loggingNotifier) NewRepo(ctx context.Context, repo *models.Repo) {
28 ctx = tlog.IntoContext(ctx, tlog.SubLogger(l.logger, "NewRepo"))
29 l.inner.NewRepo(ctx, repo)
30}
31
32func (l *loggingNotifier) NewStar(ctx context.Context, star *models.Star) {
33 ctx = tlog.IntoContext(ctx, tlog.SubLogger(l.logger, "NewStar"))
34 l.inner.NewStar(ctx, star)
35}
36
37func (l *loggingNotifier) DeleteStar(ctx context.Context, star *models.Star) {
38 ctx = tlog.IntoContext(ctx, tlog.SubLogger(l.logger, "DeleteStar"))
39 l.inner.DeleteStar(ctx, star)
40}
41
42func (l *loggingNotifier) NewIssue(ctx context.Context, issue *models.Issue, mentions []syntax.DID) {
43 ctx = tlog.IntoContext(ctx, tlog.SubLogger(l.logger, "NewIssue"))
44 l.inner.NewIssue(ctx, issue, mentions)
45}
46
47func (l *loggingNotifier) NewIssueComment(ctx context.Context, comment *models.IssueComment, mentions []syntax.DID) {
48 ctx = tlog.IntoContext(ctx, tlog.SubLogger(l.logger, "NewIssueComment"))
49 l.inner.NewIssueComment(ctx, comment, mentions)
50}
51
52func (l *loggingNotifier) NewIssueState(ctx context.Context, actor syntax.DID, issue *models.Issue) {
53 ctx = tlog.IntoContext(ctx, tlog.SubLogger(l.logger, "NewIssueState"))
54 l.inner.NewIssueState(ctx, actor, issue)
55}
56
57func (l *loggingNotifier) DeleteIssue(ctx context.Context, issue *models.Issue) {
58 ctx = tlog.IntoContext(ctx, tlog.SubLogger(l.logger, "DeleteIssue"))
59 l.inner.DeleteIssue(ctx, issue)
60}
61
62func (l *loggingNotifier) NewFollow(ctx context.Context, follow *models.Follow) {
63 ctx = tlog.IntoContext(ctx, tlog.SubLogger(l.logger, "NewFollow"))
64 l.inner.NewFollow(ctx, follow)
65}
66
67func (l *loggingNotifier) DeleteFollow(ctx context.Context, follow *models.Follow) {
68 ctx = tlog.IntoContext(ctx, tlog.SubLogger(l.logger, "DeleteFollow"))
69 l.inner.DeleteFollow(ctx, follow)
70}
71
72func (l *loggingNotifier) NewPull(ctx context.Context, pull *models.Pull) {
73 ctx = tlog.IntoContext(ctx, tlog.SubLogger(l.logger, "NewPull"))
74 l.inner.NewPull(ctx, pull)
75}
76
77func (l *loggingNotifier) NewPullComment(ctx context.Context, comment *models.PullComment, mentions []syntax.DID) {
78 ctx = tlog.IntoContext(ctx, tlog.SubLogger(l.logger, "NewPullComment"))
79 l.inner.NewPullComment(ctx, comment, mentions)
80}
81
82func (l *loggingNotifier) NewPullState(ctx context.Context, actor syntax.DID, pull *models.Pull) {
83 ctx = tlog.IntoContext(ctx, tlog.SubLogger(l.logger, "NewPullState"))
84 l.inner.NewPullState(ctx, actor, pull)
85}
86
87func (l *loggingNotifier) UpdateProfile(ctx context.Context, profile *models.Profile) {
88 ctx = tlog.IntoContext(ctx, tlog.SubLogger(l.logger, "UpdateProfile"))
89 l.inner.UpdateProfile(ctx, profile)
90}
91
92func (l *loggingNotifier) NewString(ctx context.Context, s *models.String) {
93 ctx = tlog.IntoContext(ctx, tlog.SubLogger(l.logger, "NewString"))
94 l.inner.NewString(ctx, s)
95}
96
97func (l *loggingNotifier) EditString(ctx context.Context, s *models.String) {
98 ctx = tlog.IntoContext(ctx, tlog.SubLogger(l.logger, "EditString"))
99 l.inner.EditString(ctx, s)
100}
101
102func (l *loggingNotifier) DeleteString(ctx context.Context, did, rkey string) {
103 ctx = tlog.IntoContext(ctx, tlog.SubLogger(l.logger, "DeleteString"))
104 l.inner.DeleteString(ctx, did, rkey)
105}
106
107func (l *loggingNotifier) Push(ctx context.Context, repo *models.Repo, ref, oldSha, newSha, committerDid string) {
108 ctx = tlog.IntoContext(ctx, tlog.SubLogger(l.logger, "Push"))
109 l.inner.Push(ctx, repo, ref, oldSha, newSha, committerDid)
110}