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