···
"github.com/bluesky-social/indigo/atproto/syntax"
···
"tangled.org/core/appview/notify"
"tangled.org/core/idresolver"
type databaseNotifier struct {
···
actorDid := syntax.DID(star.Did)
-
recipients := []syntax.DID{syntax.DID(repo.Did)}
eventType := models.NotificationTypeRepoStarred
entityId := star.RepoAt.String()
···
func (n *databaseNotifier) NewIssue(ctx context.Context, issue *models.Issue, mentions []syntax.DID) {
-
// build the recipients list
-
// - collaborators in the repo
-
var recipients []syntax.DID
-
recipients = append(recipients, syntax.DID(issue.Repo.Did))
collaborators, err := db.GetCollaborators(n.db, orm.FilterEq("repo_at", issue.Repo.RepoAt()))
log.Printf("failed to fetch collaborators: %v", err)
for _, c := range collaborators {
-
recipients = append(recipients, c.SubjectDid)
actorDid := syntax.DID(issue.Did)
···
models.NotificationTypeUserMentioned,
···
-
var recipients []syntax.DID
-
recipients = append(recipients, syntax.DID(issue.Repo.Did))
// if this comment is a reply, then notify everybody in that thread
parentAtUri := *comment.ReplyTo
-
allThreads := issue.CommentList()
// find the parent thread, and add all DIDs from here to the recipient list
-
for _, t := range allThreads {
if t.Self.AtUri().String() == parentAtUri {
-
recipients = append(recipients, t.Participants()...)
// not a reply, notify just the issue author
-
recipients = append(recipients, syntax.DID(issue.Did))
actorDid := syntax.DID(comment.Did)
···
models.NotificationTypeUserMentioned,
···
func (n *databaseNotifier) NewFollow(ctx context.Context, follow *models.Follow) {
actorDid := syntax.DID(follow.UserDid)
-
recipients := []syntax.DID{syntax.DID(follow.SubjectDid)}
eventType := models.NotificationTypeFollowed
entityId := follow.UserDid
···
log.Printf("NewPull: failed to get repos: %v", err)
-
// build the recipients list
-
// - collaborators in the repo
-
var recipients []syntax.DID
-
recipients = append(recipients, syntax.DID(repo.Did))
collaborators, err := db.GetCollaborators(n.db, orm.FilterEq("repo_at", repo.RepoAt()))
log.Printf("failed to fetch collaborators: %v", err)
for _, c := range collaborators {
-
recipients = append(recipients, c.SubjectDid)
actorDid := syntax.DID(pull.OwnerDid)
···
// build up the recipients list:
// - all pull participants
-
var recipients []syntax.DID
-
recipients = append(recipients, syntax.DID(repo.Did))
for _, p := range pull.Participants() {
-
recipients = append(recipients, syntax.DID(p))
actorDid := syntax.DID(comment.OwnerDid)
···
models.NotificationTypeUserMentioned,
···
func (n *databaseNotifier) NewIssueState(ctx context.Context, actor syntax.DID, issue *models.Issue) {
-
// build up the recipients list:
-
// - repo collaborators
-
// - all issue participants
-
var recipients []syntax.DID
-
recipients = append(recipients, syntax.DID(issue.Repo.Did))
collaborators, err := db.GetCollaborators(n.db, orm.FilterEq("repo_at", issue.Repo.RepoAt()))
log.Printf("failed to fetch collaborators: %v", err)
for _, c := range collaborators {
-
recipients = append(recipients, c.SubjectDid)
for _, p := range issue.Participants() {
-
recipients = append(recipients, syntax.DID(p))
···
-
// build up the recipients list:
-
// - all pull participants
-
var recipients []syntax.DID
-
recipients = append(recipients, syntax.DID(repo.Did))
collaborators, err := db.GetCollaborators(n.db, orm.FilterEq("repo_at", repo.RepoAt()))
log.Printf("failed to fetch collaborators: %v", err)
for _, c := range collaborators {
-
recipients = append(recipients, c.SubjectDid)
for _, p := range pull.Participants() {
-
recipients = append(recipients, syntax.DID(p))
···
func (n *databaseNotifier) notifyEvent(
-
recipients []syntax.DID,
eventType models.NotificationType,
···
-
if eventType == models.NotificationTypeUserMentioned && len(recipients) > maxMentions {
-
recipients = recipients[:maxMentions]
-
recipientSet := make(map[syntax.DID]struct{})
-
for _, did := range recipients {
-
// everybody except actor themselves
-
recipientSet[did] = struct{}{}
prefMap, err := db.GetNotificationPreferences(
-
orm.FilterIn("user_did", slices.Collect(maps.Keys(recipientSet))),
// failed to get prefs for users
···
// filter based on preferences
-
for recipientDid := range recipientSet {
prefs, ok := prefMap[recipientDid]
prefs = models.DefaultNotificationPreferences(recipientDid)
···
"github.com/bluesky-social/indigo/atproto/syntax"
···
"tangled.org/core/appview/notify"
"tangled.org/core/idresolver"
+
"tangled.org/oppi.li/sets"
type databaseNotifier struct {
···
actorDid := syntax.DID(star.Did)
+
recipients := sets.Singleton(syntax.DID(repo.Did))
eventType := models.NotificationTypeRepoStarred
entityId := star.RepoAt.String()
···
func (n *databaseNotifier) NewIssue(ctx context.Context, issue *models.Issue, mentions []syntax.DID) {
collaborators, err := db.GetCollaborators(n.db, orm.FilterEq("repo_at", issue.Repo.RepoAt()))
log.Printf("failed to fetch collaborators: %v", err)
+
// build the recipients list
+
// - collaborators in the repo
+
// - remove users already mentioned
+
recipients := sets.Singleton(syntax.DID(issue.Repo.Did))
for _, c := range collaborators {
+
recipients.Insert(c.SubjectDid)
+
for _, m := range mentions {
actorDid := syntax.DID(issue.Did)
···
+
sets.Collect(slices.Values(mentions)),
models.NotificationTypeUserMentioned,
···
+
// built the recipients list:
+
// - the owner of the repo
+
// - | if the comment is a reply -> everybody on that thread
+
// | if the comment is a top level -> just the issue owner
+
// - remove mentioned users from the recipients list
+
recipients := sets.Singleton(syntax.DID(issue.Repo.Did))
// if this comment is a reply, then notify everybody in that thread
parentAtUri := *comment.ReplyTo
// find the parent thread, and add all DIDs from here to the recipient list
+
for _, t := range issue.CommentList() {
if t.Self.AtUri().String() == parentAtUri {
+
for _, p := range t.Participants() {
// not a reply, notify just the issue author
+
recipients.Insert(syntax.DID(issue.Did))
+
for _, m := range mentions {
actorDid := syntax.DID(comment.Did)
···
+
sets.Collect(slices.Values(mentions)),
models.NotificationTypeUserMentioned,
···
func (n *databaseNotifier) NewFollow(ctx context.Context, follow *models.Follow) {
actorDid := syntax.DID(follow.UserDid)
+
recipients := sets.Singleton(syntax.DID(follow.SubjectDid))
eventType := models.NotificationTypeFollowed
entityId := follow.UserDid
···
log.Printf("NewPull: failed to get repos: %v", err)
collaborators, err := db.GetCollaborators(n.db, orm.FilterEq("repo_at", repo.RepoAt()))
log.Printf("failed to fetch collaborators: %v", err)
+
// build the recipients list
+
// - collaborators in the repo
+
recipients := sets.Singleton(syntax.DID(repo.Did))
for _, c := range collaborators {
+
recipients.Insert(c.SubjectDid)
actorDid := syntax.DID(pull.OwnerDid)
···
// build up the recipients list:
// - all pull participants
+
// - remove those already mentioned
+
recipients := sets.Singleton(syntax.DID(repo.Did))
for _, p := range pull.Participants() {
+
recipients.Insert(syntax.DID(p))
+
for _, m := range mentions {
actorDid := syntax.DID(comment.OwnerDid)
···
+
sets.Collect(slices.Values(mentions)),
models.NotificationTypeUserMentioned,
···
func (n *databaseNotifier) NewIssueState(ctx context.Context, actor syntax.DID, issue *models.Issue) {
collaborators, err := db.GetCollaborators(n.db, orm.FilterEq("repo_at", issue.Repo.RepoAt()))
log.Printf("failed to fetch collaborators: %v", err)
+
// build up the recipients list:
+
// - repo collaborators
+
// - all issue participants
+
recipients := sets.Singleton(syntax.DID(issue.Repo.Did))
for _, c := range collaborators {
+
recipients.Insert(c.SubjectDid)
for _, p := range issue.Participants() {
+
recipients.Insert(syntax.DID(p))
···
collaborators, err := db.GetCollaborators(n.db, orm.FilterEq("repo_at", repo.RepoAt()))
log.Printf("failed to fetch collaborators: %v", err)
+
// build up the recipients list:
+
// - all pull participants
+
recipients := sets.Singleton(syntax.DID(repo.Did))
for _, c := range collaborators {
+
recipients.Insert(c.SubjectDid)
for _, p := range pull.Participants() {
+
recipients.Insert(syntax.DID(p))
···
func (n *databaseNotifier) notifyEvent(
+
recipients sets.Set[syntax.DID],
eventType models.NotificationType,
···
+
// if the user is attempting to mention >maxMentions users, this is probably spam, do not mention anybody
+
if eventType == models.NotificationTypeUserMentioned && recipients.Len() > maxMentions {
+
recipients.Remove(actorDid)
prefMap, err := db.GetNotificationPreferences(
+
orm.FilterIn("user_did", slices.Collect(recipients.All())),
// failed to get prefs for users
···
// filter based on preferences
+
for recipientDid := range recipients.All() {
prefs, ok := prefMap[recipientDid]
prefs = models.DefaultNotificationPreferences(recipientDid)