grain.social is a photo sharing platform built on atproto. grain.social
atproto photography appview
51
fork

Configure Feed

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

at main 26 lines 895 B view raw
1import { defineHook } from "$hatk"; 2import { shouldPush } from "../helpers/notifPrefs.ts"; 3import { getUnseenCount } from "../helpers/unseenCount.ts"; 4 5export default defineHook("on-commit", { collections: ["social.grain.graph.follow"] }, 6 async ({ action, record, repo, db, lookup, push }) => { 7 if (action !== "create" || !record) return 8 9 const subject = record.subject as string 10 if (!subject || subject === repo) return 11 12 if (!(await shouldPush(db, subject, repo, "follows"))) return 13 14 const profiles = await lookup("social.grain.actor.profile", "did", [repo]) 15 const actor = profiles.get(repo) 16 17 const badge = await getUnseenCount(db, subject) + 1 18 await push.send({ 19 did: subject, 20 title: "New follower", 21 body: `${(actor?.value as any)?.displayName ?? "Someone"} followed you`, 22 data: { type: "follow", did: repo }, 23 badge, 24 }) 25 } 26)