···
331
-
func (n *databaseNotifier) NewPullMerged(ctx context.Context, pull *models.Pull) {
331
+
func (n *databaseNotifier) NewPullState(ctx context.Context, pull *models.Pull) {
repo, err := db.GetRepo(n.db, db.FilterEq("at_uri", string(pull.RepoAt)))
335
-
log.Printf("NewPullMerged: failed to get repos: %v", err)
335
+
log.Printf("NewPullState: failed to get repos: %v", err)
···
actorDid := syntax.DID(repo.Did)
357
-
eventType := models.NotificationTypePullMerged
entityId := pull.PullAt().String()
362
-
p := int64(pull.ID)
377
-
func (n *databaseNotifier) NewPullClosed(ctx context.Context, pull *models.Pull) {
378
-
// Get repo details
379
-
repo, err := db.GetRepo(n.db, db.FilterEq("at_uri", string(pull.RepoAt)))
381
-
log.Printf("NewPullMerged: failed to get repos: %v", err)
385
-
// build up the recipients list:
387
-
// - all pull participants
388
-
var recipients []syntax.DID
389
-
recipients = append(recipients, syntax.DID(repo.Did))
390
-
collaborators, err := db.GetCollaborators(n.db, db.FilterEq("repo_at", repo.RepoAt()))
392
-
log.Printf("failed to fetch collaborators: %v", err)
395
-
for _, c := range collaborators {
396
-
recipients = append(recipients, c.SubjectDid)
398
-
for _, p := range pull.Participants() {
399
-
recipients = append(recipients, syntax.DID(p))
402
-
actorDid := syntax.DID(repo.Did)
403
-
eventType := models.NotificationTypePullClosed
404
-
entityType := "pull"
405
-
entityId := pull.PullAt().String()
408
-
p := int64(pull.ID)
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)))
427
-
log.Printf("NewPullMerged: failed to get repos: %v", err)
431
-
// build up the recipients list:
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()))
438
-
log.Printf("failed to fetch collaborators: %v", err)
361
+
var eventType models.NotificationType
362
+
switch pull.State {
363
+
case models.PullClosed:
364
+
eventType = models.NotificationTypePullClosed
365
+
case models.PullOpen:
366
+
eventType = models.NotificationTypePullReopen
367
+
case models.PullMerged:
368
+
eventType = models.NotificationTypePullMerged
370
+
log.Println("NewPullState: unexpected new PR state:", pull.State)
441
-
for _, c := range collaborators {
442
-
recipients = append(recipients, c.SubjectDid)
444
-
for _, p := range pull.Participants() {
445
-
recipients = append(recipients, syntax.DID(p))
448
-
actorDid := syntax.DID(repo.Did)
449
-
eventType := models.NotificationTypePullReopen
450
-
entityType := "pull"
451
-
entityId := pull.PullAt().String()