Signed-off-by: Seongmin Lee git@boltless.me
+2
-2
appview/indexer/notifier.go
+2
-2
appview/indexer/notifier.go
···
19
}
20
}
21
22
-
func (ix *Indexer) NewIssueState(ctx context.Context, issue *models.Issue) {
23
l := log.FromContext(ctx).With("notifier", "indexer", "issue", issue)
24
l.Debug("updating an issue")
25
err := ix.Issues.Index(ctx, *issue)
···
46
}
47
}
48
49
-
func (ix *Indexer) NewPullState(ctx context.Context, pull *models.Pull) {
50
l := log.FromContext(ctx).With("notifier", "indexer", "pull", pull)
51
l.Debug("updating a pr")
52
err := ix.Pulls.Index(ctx, pull)
···
19
}
20
}
21
22
+
func (ix *Indexer) NewIssueState(ctx context.Context, actor syntax.DID, issue *models.Issue) {
23
l := log.FromContext(ctx).With("notifier", "indexer", "issue", issue)
24
l.Debug("updating an issue")
25
err := ix.Issues.Index(ctx, *issue)
···
46
}
47
}
48
49
+
func (ix *Indexer) NewPullState(ctx context.Context, actor syntax.DID, pull *models.Pull) {
50
l := log.FromContext(ctx).With("notifier", "indexer", "pull", pull)
51
l.Debug("updating a pr")
52
err := ix.Pulls.Index(ctx, pull)
+2
-2
appview/issues/issues.go
+2
-2
appview/issues/issues.go
···
309
issue.Open = false
310
311
// notify about the issue closure
312
-
rp.notifier.NewIssueState(r.Context(), issue)
313
314
rp.pages.HxLocation(w, fmt.Sprintf("/%s/issues/%d", f.OwnerSlashRepo(), issue.IssueId))
315
return
···
359
issue.Open = true
360
361
// notify about the issue reopen
362
-
rp.notifier.NewIssueState(r.Context(), issue)
363
364
rp.pages.HxLocation(w, fmt.Sprintf("/%s/issues/%d", f.OwnerSlashRepo(), issue.IssueId))
365
return
···
309
issue.Open = false
310
311
// notify about the issue closure
312
+
rp.notifier.NewIssueState(r.Context(), syntax.DID(user.Did), issue)
313
314
rp.pages.HxLocation(w, fmt.Sprintf("/%s/issues/%d", f.OwnerSlashRepo(), issue.IssueId))
315
return
···
359
issue.Open = true
360
361
// notify about the issue reopen
362
+
rp.notifier.NewIssueState(r.Context(), syntax.DID(user.Did), issue)
363
364
rp.pages.HxLocation(w, fmt.Sprintf("/%s/issues/%d", f.OwnerSlashRepo(), issue.IssueId))
365
return
+4
-6
appview/notify/db/db.go
+4
-6
appview/notify/db/db.go
···
283
// no-op
284
}
285
286
-
func (n *databaseNotifier) NewIssueState(ctx context.Context, issue *models.Issue) {
287
// build up the recipients list:
288
// - repo owner
289
// - repo collaborators
···
302
recipients = append(recipients, syntax.DID(p))
303
}
304
305
-
actorDid := syntax.DID(issue.Repo.Did)
306
entityType := "pull"
307
entityId := issue.AtUri().String()
308
repoId := &issue.Repo.Id
···
317
}
318
319
n.notifyEvent(
320
-
actorDid,
321
recipients,
322
eventType,
323
entityType,
···
328
)
329
}
330
331
-
func (n *databaseNotifier) NewPullState(ctx context.Context, pull *models.Pull) {
332
// Get repo details
333
repo, err := db.GetRepo(n.db, db.FilterEq("at_uri", string(pull.RepoAt)))
334
if err != nil {
···
353
recipients = append(recipients, syntax.DID(p))
354
}
355
356
-
actorDid := syntax.DID(repo.Did)
357
entityType := "pull"
358
entityId := pull.PullAt().String()
359
repoId := &repo.Id
···
374
pullId := &p
375
376
n.notifyEvent(
377
-
actorDid,
378
recipients,
379
eventType,
380
entityType,
···
283
// no-op
284
}
285
286
+
func (n *databaseNotifier) NewIssueState(ctx context.Context, actor syntax.DID, issue *models.Issue) {
287
// build up the recipients list:
288
// - repo owner
289
// - repo collaborators
···
302
recipients = append(recipients, syntax.DID(p))
303
}
304
305
entityType := "pull"
306
entityId := issue.AtUri().String()
307
repoId := &issue.Repo.Id
···
316
}
317
318
n.notifyEvent(
319
+
actor,
320
recipients,
321
eventType,
322
entityType,
···
327
)
328
}
329
330
+
func (n *databaseNotifier) NewPullState(ctx context.Context, actor syntax.DID, pull *models.Pull) {
331
// Get repo details
332
repo, err := db.GetRepo(n.db, db.FilterEq("at_uri", string(pull.RepoAt)))
333
if err != nil {
···
352
recipients = append(recipients, syntax.DID(p))
353
}
354
355
entityType := "pull"
356
entityId := pull.PullAt().String()
357
repoId := &repo.Id
···
372
pullId := &p
373
374
n.notifyEvent(
375
+
actor,
376
recipients,
377
eventType,
378
entityType,
+4
-4
appview/notify/merged_notifier.go
+4
-4
appview/notify/merged_notifier.go
···
61
m.fanout("NewIssueComment", ctx, comment)
62
}
63
64
-
func (m *mergedNotifier) NewIssueState(ctx context.Context, issue *models.Issue) {
65
-
m.fanout("NewIssueState", ctx, issue)
66
}
67
68
func (m *mergedNotifier) DeleteIssue(ctx context.Context, issue *models.Issue) {
···
85
m.fanout("NewPullComment", ctx, comment)
86
}
87
88
-
func (m *mergedNotifier) NewPullState(ctx context.Context, pull *models.Pull) {
89
-
m.fanout("NewPullState", ctx, pull)
90
}
91
92
func (m *mergedNotifier) UpdateProfile(ctx context.Context, profile *models.Profile) {
···
61
m.fanout("NewIssueComment", ctx, comment)
62
}
63
64
+
func (m *mergedNotifier) NewIssueState(ctx context.Context, actor syntax.DID, issue *models.Issue) {
65
+
m.fanout("NewIssueState", ctx, actor, issue)
66
}
67
68
func (m *mergedNotifier) DeleteIssue(ctx context.Context, issue *models.Issue) {
···
85
m.fanout("NewPullComment", ctx, comment)
86
}
87
88
+
func (m *mergedNotifier) NewPullState(ctx context.Context, actor syntax.DID, pull *models.Pull) {
89
+
m.fanout("NewPullState", ctx, actor, pull)
90
}
91
92
func (m *mergedNotifier) UpdateProfile(ctx context.Context, profile *models.Profile) {
+10
-9
appview/notify/notifier.go
+10
-9
appview/notify/notifier.go
···
3
import (
4
"context"
5
6
"tangled.org/core/appview/models"
7
)
8
···
14
15
NewIssue(ctx context.Context, issue *models.Issue)
16
NewIssueComment(ctx context.Context, comment *models.IssueComment)
17
-
NewIssueState(ctx context.Context, issue *models.Issue)
18
DeleteIssue(ctx context.Context, issue *models.Issue)
19
20
NewFollow(ctx context.Context, follow *models.Follow)
···
22
23
NewPull(ctx context.Context, pull *models.Pull)
24
NewPullComment(ctx context.Context, comment *models.PullComment)
25
-
NewPullState(ctx context.Context, pull *models.Pull)
26
27
UpdateProfile(ctx context.Context, profile *models.Profile)
28
···
41
func (m *BaseNotifier) NewStar(ctx context.Context, star *models.Star) {}
42
func (m *BaseNotifier) DeleteStar(ctx context.Context, star *models.Star) {}
43
44
-
func (m *BaseNotifier) NewIssue(ctx context.Context, issue *models.Issue) {}
45
-
func (m *BaseNotifier) NewIssueComment(ctx context.Context, comment *models.IssueComment) {}
46
-
func (m *BaseNotifier) NewIssueState(ctx context.Context, issue *models.Issue) {}
47
-
func (m *BaseNotifier) DeleteIssue(ctx context.Context, issue *models.Issue) {}
48
49
func (m *BaseNotifier) NewFollow(ctx context.Context, follow *models.Follow) {}
50
func (m *BaseNotifier) DeleteFollow(ctx context.Context, follow *models.Follow) {}
51
52
-
func (m *BaseNotifier) NewPull(ctx context.Context, pull *models.Pull) {}
53
-
func (m *BaseNotifier) NewPullComment(ctx context.Context, models *models.PullComment) {}
54
-
func (m *BaseNotifier) NewPullState(ctx context.Context, pull *models.Pull) {}
55
56
func (m *BaseNotifier) UpdateProfile(ctx context.Context, profile *models.Profile) {}
57
···
3
import (
4
"context"
5
6
+
"github.com/bluesky-social/indigo/atproto/syntax"
7
"tangled.org/core/appview/models"
8
)
9
···
15
16
NewIssue(ctx context.Context, issue *models.Issue)
17
NewIssueComment(ctx context.Context, comment *models.IssueComment)
18
+
NewIssueState(ctx context.Context, actor syntax.DID, issue *models.Issue)
19
DeleteIssue(ctx context.Context, issue *models.Issue)
20
21
NewFollow(ctx context.Context, follow *models.Follow)
···
23
24
NewPull(ctx context.Context, pull *models.Pull)
25
NewPullComment(ctx context.Context, comment *models.PullComment)
26
+
NewPullState(ctx context.Context, actor syntax.DID, pull *models.Pull)
27
28
UpdateProfile(ctx context.Context, profile *models.Profile)
29
···
42
func (m *BaseNotifier) NewStar(ctx context.Context, star *models.Star) {}
43
func (m *BaseNotifier) DeleteStar(ctx context.Context, star *models.Star) {}
44
45
+
func (m *BaseNotifier) NewIssue(ctx context.Context, issue *models.Issue) {}
46
+
func (m *BaseNotifier) NewIssueComment(ctx context.Context, comment *models.IssueComment) {}
47
+
func (m *BaseNotifier) NewIssueState(ctx context.Context, actor syntax.DID, issue *models.Issue) {}
48
+
func (m *BaseNotifier) DeleteIssue(ctx context.Context, issue *models.Issue) {}
49
50
func (m *BaseNotifier) NewFollow(ctx context.Context, follow *models.Follow) {}
51
func (m *BaseNotifier) DeleteFollow(ctx context.Context, follow *models.Follow) {}
52
53
+
func (m *BaseNotifier) NewPull(ctx context.Context, pull *models.Pull) {}
54
+
func (m *BaseNotifier) NewPullComment(ctx context.Context, models *models.PullComment) {}
55
+
func (m *BaseNotifier) NewPullState(ctx context.Context, actor syntax.DID, pull *models.Pull) {}
56
57
func (m *BaseNotifier) UpdateProfile(ctx context.Context, profile *models.Profile) {}
58
+4
-2
appview/notify/posthog/notifier.go
+4
-2
appview/notify/posthog/notifier.go
···
190
}
191
}
192
193
-
func (n *posthogNotifier) NewIssueState(ctx context.Context, issue *models.Issue) {
194
var event string
195
if issue.Open {
196
event = "issue_reopen"
···
202
Event: event,
203
Properties: posthog.Properties{
204
"repo_at": issue.RepoAt.String(),
205
"issue_id": issue.IssueId,
206
},
207
})
···
210
}
211
}
212
213
-
func (n *posthogNotifier) NewPullState(ctx context.Context, pull *models.Pull) {
214
var event string
215
switch pull.State {
216
case models.PullClosed:
···
229
Properties: posthog.Properties{
230
"repo_at": pull.RepoAt,
231
"pull_id": pull.PullId,
232
},
233
})
234
if err != nil {
···
190
}
191
}
192
193
+
func (n *posthogNotifier) NewIssueState(ctx context.Context, actor syntax.DID, issue *models.Issue) {
194
var event string
195
if issue.Open {
196
event = "issue_reopen"
···
202
Event: event,
203
Properties: posthog.Properties{
204
"repo_at": issue.RepoAt.String(),
205
+
"actor": actor,
206
"issue_id": issue.IssueId,
207
},
208
})
···
211
}
212
}
213
214
+
func (n *posthogNotifier) NewPullState(ctx context.Context, actor syntax.DID, pull *models.Pull) {
215
var event string
216
switch pull.State {
217
case models.PullClosed:
···
230
Properties: posthog.Properties{
231
"repo_at": pull.RepoAt,
232
"pull_id": pull.PullId,
233
+
"actor": actor,
234
},
235
})
236
if err != nil {
+4
-3
appview/pulls/pulls.go
+4
-3
appview/pulls/pulls.go
···
2106
}
2107
2108
func (s *Pulls) MergePull(w http.ResponseWriter, r *http.Request) {
2109
f, err := s.repoResolver.Resolve(r)
2110
if err != nil {
2111
log.Println("failed to resolve repo:", err)
···
2216
2217
// notify about the pull merge
2218
for _, p := range pullsToMerge {
2219
-
s.notifier.NewPullState(r.Context(), p)
2220
}
2221
2222
s.pages.HxLocation(w, fmt.Sprintf("/@%s/%s/pulls/%d", f.OwnerHandle(), f.Name, pull.PullId))
···
2288
}
2289
2290
for _, p := range pullsToClose {
2291
-
s.notifier.NewPullState(r.Context(), p)
2292
}
2293
2294
s.pages.HxLocation(w, fmt.Sprintf("/%s/pulls/%d", f.OwnerSlashRepo(), pull.PullId))
···
2361
}
2362
2363
for _, p := range pullsToReopen {
2364
-
s.notifier.NewPullState(r.Context(), p)
2365
}
2366
2367
s.pages.HxLocation(w, fmt.Sprintf("/%s/pulls/%d", f.OwnerSlashRepo(), pull.PullId))
···
2106
}
2107
2108
func (s *Pulls) MergePull(w http.ResponseWriter, r *http.Request) {
2109
+
user := s.oauth.GetUser(r)
2110
f, err := s.repoResolver.Resolve(r)
2111
if err != nil {
2112
log.Println("failed to resolve repo:", err)
···
2217
2218
// notify about the pull merge
2219
for _, p := range pullsToMerge {
2220
+
s.notifier.NewPullState(r.Context(), syntax.DID(user.Did), p)
2221
}
2222
2223
s.pages.HxLocation(w, fmt.Sprintf("/@%s/%s/pulls/%d", f.OwnerHandle(), f.Name, pull.PullId))
···
2289
}
2290
2291
for _, p := range pullsToClose {
2292
+
s.notifier.NewPullState(r.Context(), syntax.DID(user.Did), p)
2293
}
2294
2295
s.pages.HxLocation(w, fmt.Sprintf("/%s/pulls/%d", f.OwnerSlashRepo(), pull.PullId))
···
2362
}
2363
2364
for _, p := range pullsToReopen {
2365
+
s.notifier.NewPullState(r.Context(), syntax.DID(user.Did), p)
2366
}
2367
2368
s.pages.HxLocation(w, fmt.Sprintf("/%s/pulls/%d", f.OwnerSlashRepo(), pull.PullId))
History
5 rounds
1 comment
boltless.me
submitted
#4
1 commit
expand
collapse
appview/notify: use correct actor on issue/pr state change events
Signed-off-by: Seongmin Lee <git@boltless.me>
3/3 success
expand
collapse
expand 0 comments
pull request successfully merged
boltless.me
submitted
#3
1 commit
expand
collapse
appview/notify: use correct actor on issue/pr state change events
Signed-off-by: Seongmin Lee <git@boltless.me>
3/3 success
expand
collapse
expand 0 comments
boltless.me
submitted
#2
1 commit
expand
collapse
appview/notify: use correct actor on issue/pr state change events
Signed-off-by: Seongmin Lee <git@boltless.me>
1/3 failed, 1/3 timeout, 1/3 success
expand
collapse
expand 0 comments
boltless.me
submitted
#1
1 commit
expand
collapse
appview/notify: use correct actor on issue/pr state change events
Signed-off-by: Seongmin Lee <git@boltless.me>
1/3 failed, 2/3 timeout
expand
collapse
expand 0 comments
boltless.me
submitted
#0
1 commit
expand
collapse
appview/notify: use correct actor on issue/pr state change events
Signed-off-by: Seongmin Lee <git@boltless.me>
this is valuable as an interim fix! as you know, we are looking to atprotate issue state and PR state changes.
can you move this off of this stack? can be opened as a standalone PR.