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

Configure Feed

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

at main 27 lines 865 B view raw
1/** Label values that cause content to be filtered from feeds (imperative + defaultSetting:"hide"). */ 2export const HIDE_LABELS = new Set([ 3 "!hide", 4 "!takedown", 5 "spam", 6 "copyright", 7 "gore", 8 "nsfl", 9 "dmca-violation", 10 "doxxing", 11]); 12 13/** SQL fragment: NOT EXISTS subquery filtering rows with hide-severity labels. 14 * A label is only active if its latest row (by cts) has neg = 0. 15 * `uriExpr` is the column to match against (e.g. "t.uri"). */ 16export function hideLabelsFilter(uriExpr: string): string { 17 const inList = [...HIDE_LABELS].map((v) => `'${v}'`).join(","); 18 return `NOT EXISTS ( 19 SELECT 1 FROM _labels l 20 WHERE l.uri = ${uriExpr} AND l.val IN (${inList}) 21 AND l.neg = 0 22 AND NOT EXISTS ( 23 SELECT 1 FROM _labels l2 24 WHERE l2.uri = l.uri AND l2.val = l.val AND l2.neg = 1 AND l2.cts > l.cts 25 ) 26 )`; 27}