Monorepo for Tangled
0

Configure Feed

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

appview/notify/db: apply subscription overrides and auto-subscribe actors

Signed-off-by: Anirudh Oppiliappan <x@icyphox.sh>

author
Anirudh Oppiliappan
committer
Anirudh Oppiliappan
date (Jul 17, 2026, 9:10 AM +0300) commit 525f5412 parent bcacaefa change-id smotrpxo
+47
+47
appview/notify/db/db.go
··· 553 553 554 554 recipients.Remove(actorDid) 555 555 556 + // Apply subscription overrides for thread-activity events only. 557 + // Mention and assignment events are targeted at specific users and should 558 + // not be broadcast to all thread subscribers. 559 + isThreadEvent := eventType != models.NotificationTypeUserMentioned && 560 + eventType != models.NotificationTypeIssueAssigned && 561 + eventType != models.NotificationTypeIssueUnassigned && 562 + eventType != models.NotificationTypePullAssigned && 563 + eventType != models.NotificationTypePullUnassigned 564 + 565 + switch { 566 + case issueId != nil && isThreadEvent: 567 + if subs, err := db.GetIssueSubscribers(n.db, *issueId); err == nil { 568 + for _, did := range subs { 569 + recipients.Insert(syntax.DID(did)) 570 + } 571 + } 572 + if unsubs, err := db.GetIssueUnsubscribers(n.db, *issueId); err == nil { 573 + for _, did := range unsubs { 574 + recipients.Remove(syntax.DID(did)) 575 + } 576 + } 577 + case pullId != nil && isThreadEvent: 578 + if subs, err := db.GetPullSubscribers(n.db, *pullId); err == nil { 579 + for _, did := range subs { 580 + recipients.Insert(syntax.DID(did)) 581 + } 582 + } 583 + if unsubs, err := db.GetPullUnsubscribers(n.db, *pullId); err == nil { 584 + for _, did := range unsubs { 585 + recipients.Remove(syntax.DID(did)) 586 + } 587 + } 588 + } 589 + 590 + // Auto-subscribe the actor to this issue/pull when they interact with it. 591 + // This happens outside the transaction since it’s best-effort. 592 + switch { 593 + case issueId != nil: 594 + if err := db.UpsertIssueSubscription(n.db, actorDid.String(), *issueId, true); err != nil { 595 + l.Warn("failed to auto-subscribe actor to issue", "actor", actorDid, "issueId", *issueId, "err", err) 596 + } 597 + case pullId != nil: 598 + if err := db.UpsertPullSubscription(n.db, actorDid.String(), *pullId, true); err != nil { 599 + l.Warn("failed to auto-subscribe actor to pull", "actor", actorDid, "pullId", *pullId, "err", err) 600 + } 601 + } 602 + 556 603 prefMap, err := db.GetNotificationPreferences( 557 604 n.db, 558 605 orm.FilterIn("user_did", slices.Collect(recipients.All())),