+5
appview/models/notifications.go
+5
appview/models/notifications.go
···
19
NotificationTypeIssueClosed NotificationType = "issue_closed"
20
NotificationTypeIssueReopen NotificationType = "issue_reopen"
21
NotificationTypePullClosed NotificationType = "pull_closed"
22
)
23
24
type Notification struct {
···
58
return "git-merge"
59
case NotificationTypePullClosed:
60
return "git-pull-request-closed"
61
case NotificationTypeFollowed:
62
return "user-plus"
63
default:
···
106
return prefs.PullMerged
107
case NotificationTypePullClosed:
108
return prefs.PullMerged // same pref for now
109
case NotificationTypeFollowed:
110
return prefs.Followed
111
default:
···
19
NotificationTypeIssueClosed NotificationType = "issue_closed"
20
NotificationTypeIssueReopen NotificationType = "issue_reopen"
21
NotificationTypePullClosed NotificationType = "pull_closed"
22
+
NotificationTypePullReopen NotificationType = "pull_reopen"
23
)
24
25
type Notification struct {
···
59
return "git-merge"
60
case NotificationTypePullClosed:
61
return "git-pull-request-closed"
62
+
case NotificationTypePullReopen:
63
+
return "git-pull-request-create"
64
case NotificationTypeFollowed:
65
return "user-plus"
66
default:
···
109
return prefs.PullMerged
110
case NotificationTypePullClosed:
111
return prefs.PullMerged // same pref for now
112
+
case NotificationTypePullReopen:
113
+
return prefs.PullCreated // same pref for now
114
case NotificationTypeFollowed:
115
return prefs.Followed
116
default:
+46
appview/notify/db/db.go
+46
appview/notify/db/db.go
···
420
)
421
}
422
423
+
func (n *databaseNotifier) NewPullReopen(ctx context.Context, pull *models.Pull) {
424
+
// Get repo details
425
+
repo, err := db.GetRepo(n.db, db.FilterEq("at_uri", string(pull.RepoAt)))
426
+
if err != nil {
427
+
log.Printf("NewPullMerged: failed to get repos: %v", err)
428
+
return
429
+
}
430
+
431
+
// build up the recipients list:
432
+
// - repo owner
433
+
// - all pull participants
434
+
var recipients []syntax.DID
435
+
recipients = append(recipients, syntax.DID(repo.Did))
436
+
collaborators, err := db.GetCollaborators(n.db, db.FilterEq("repo_at", repo.RepoAt()))
437
+
if err != nil {
438
+
log.Printf("failed to fetch collaborators: %v", err)
439
+
return
440
+
}
441
+
for _, c := range collaborators {
442
+
recipients = append(recipients, c.SubjectDid)
443
+
}
444
+
for _, p := range pull.Participants() {
445
+
recipients = append(recipients, syntax.DID(p))
446
+
}
447
+
448
+
actorDid := syntax.DID(repo.Did)
449
+
eventType := models.NotificationTypePullReopen
450
+
entityType := "pull"
451
+
entityId := pull.PullAt().String()
452
+
repoId := &repo.Id
453
+
var issueId *int64
454
+
p := int64(pull.ID)
455
+
pullId := &p
456
+
457
+
n.notifyEvent(
458
+
actorDid,
459
+
recipients,
460
+
eventType,
461
+
entityType,
462
+
entityId,
463
+
repoId,
464
+
issueId,
465
+
pullId,
466
+
)
467
+
}
468
+
469
func (n *databaseNotifier) notifyEvent(
470
actorDid syntax.DID,
471
recipients []syntax.DID,
+4
appview/notify/merged_notifier.go
+4
appview/notify/merged_notifier.go
···
93
m.fanout("NewPullClosed", ctx, pull)
94
}
95
96
+
func (m *mergedNotifier) NewPullReopen(ctx context.Context, pull *models.Pull) {
97
+
m.fanout("NewPullReopen", ctx, pull)
98
+
}
99
+
100
func (m *mergedNotifier) UpdateProfile(ctx context.Context, profile *models.Profile) {
101
m.fanout("UpdateProfile", ctx, profile)
102
}
+2
appview/notify/notifier.go
+2
appview/notify/notifier.go
···
24
NewPullComment(ctx context.Context, comment *models.PullComment)
25
NewPullMerged(ctx context.Context, pull *models.Pull)
26
NewPullClosed(ctx context.Context, pull *models.Pull)
27
28
UpdateProfile(ctx context.Context, profile *models.Profile)
29
···
54
func (m *BaseNotifier) NewPullComment(ctx context.Context, models *models.PullComment) {}
55
func (m *BaseNotifier) NewPullMerged(ctx context.Context, pull *models.Pull) {}
56
func (m *BaseNotifier) NewPullClosed(ctx context.Context, pull *models.Pull) {}
57
58
func (m *BaseNotifier) UpdateProfile(ctx context.Context, profile *models.Profile) {}
59
···
24
NewPullComment(ctx context.Context, comment *models.PullComment)
25
NewPullMerged(ctx context.Context, pull *models.Pull)
26
NewPullClosed(ctx context.Context, pull *models.Pull)
27
+
NewPullReopen(ctx context.Context, pull *models.Pull)
28
29
UpdateProfile(ctx context.Context, profile *models.Profile)
30
···
55
func (m *BaseNotifier) NewPullComment(ctx context.Context, models *models.PullComment) {}
56
func (m *BaseNotifier) NewPullMerged(ctx context.Context, pull *models.Pull) {}
57
func (m *BaseNotifier) NewPullClosed(ctx context.Context, pull *models.Pull) {}
58
+
func (m *BaseNotifier) NewPullReopen(ctx context.Context, pull *models.Pull) {}
59
60
func (m *BaseNotifier) UpdateProfile(ctx context.Context, profile *models.Profile) {}
61
+2
appview/pages/templates/notifications/fragments/item.html
+2
appview/pages/templates/notifications/fragments/item.html
+4
appview/pulls/pulls.go
+4
appview/pulls/pulls.go