Monorepo for Tangled tangled.org
8

Configure Feed

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

appview/db: mark notifications as read upon page visit

when visiting an issue or a pull, automatically mark any notifications
related to that issue/pull as read.

Signed-off-by: oppiliappan <me@oppi.li>

author
oppiliappan
committer
Lewis
date (May 29, 2026, 2:50 PM +0300) commit 45a22725 parent 36bf8cca change-id okqlzvqu
+44
+22
appview/db/notifications.go
··· 331 331 return nil 332 332 } 333 333 334 + func MarkNotificationsReadForIssue(e Execer, userDID, repoDid string, issueNum int) error { 335 + query := ` 336 + update notifications set read = 1 337 + where recipient_did = ? 338 + and read = 0 339 + and issue_id = (select id from issues where repo_did = ? and issue_id = ?) 340 + ` 341 + _, err := e.Exec(query, userDID, repoDid, issueNum) 342 + return err 343 + } 344 + 345 + func MarkNotificationsReadForPull(e Execer, userDID, repoDid string, pullNum int) error { 346 + query := ` 347 + update notifications set read = 1 348 + where recipient_did = ? 349 + and read = 0 350 + and pull_id = (select p.id from pulls p where p.pull_id = ? and p.repo_did = ?) 351 + ` 352 + _, err := e.Exec(query, userDID, pullNum, repoDid) 353 + return err 354 + } 355 + 334 356 func MarkNotificationUnread(e Execer, notificationID int64, userDID string) error { 335 357 idFilter := orm.FilterEq("id", notificationID) 336 358 recipientFilter := orm.FilterEq("recipient_did", userDID)
+11
appview/issues/issues.go
··· 99 99 return 100 100 } 101 101 102 + if user != nil { 103 + repoDid := f.RepoDid 104 + userDid := user.Did 105 + issueId := issue.IssueId 106 + go func() { 107 + if err := db.MarkNotificationsReadForIssue(rp.db, userDid, repoDid, issueId); err != nil { 108 + l.Error("failed to mark issue notifications as read", "err", err) 109 + } 110 + }() 111 + } 112 + 102 113 entities := []syntax.ATURI{issue.AtUri()} 103 114 for _, c := range issue.Comments { 104 115 entities = append(entities, c.FeedCommentAtUri())
+11
appview/pulls/single.go
··· 102 102 } 103 103 l = l.With("pull_id", pull.PullId, "pull_owner", pull.OwnerDid) 104 104 105 + if user != nil { 106 + repoDid := f.RepoDid 107 + userDid := user.Did 108 + pullId := pull.PullId 109 + go func() { 110 + if err := db.MarkNotificationsReadForPull(s.db, userDid, repoDid, pullId); err != nil { 111 + l.Error("failed to mark pull notifications as read", "err", err) 112 + } 113 + }() 114 + } 115 + 105 116 backlinks, err := db.GetBacklinks(s.db, pull.AtUri()) 106 117 if err != nil { 107 118 l.Error("failed to get pull backlinks", "err", err)