Monorepo for Tangled tangled.org
6

Configure Feed

Select the types of activity you want to include in your feed.

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