Retro Bulletin Board Systems on atproto. Web app and TUI. lazy mirror of alyraffauf/atbbs atbbs.xyz
forums python tui atproto bbs
3
fork

Configure Feed

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

at master 39 lines 1.3 kB view raw
1/** Lookup tables for a BBS's moderation state: who is banned, which posts 2 * are hidden, and the rkeys of those records (so the sysop can undo). */ 3 4import { listRecords } from "./atproto"; 5import { BAN, HIDE } from "./lexicon"; 6import { parseAtUri } from "./util"; 7import { isBanRecord, isHideRecord } from "./recordGuards"; 8 9// Fields must be JSON-safe — this shape is persisted via localStorage. 10export interface BBSModeration { 11 /** DID → rkey of that user's ban record on the sysop's PDS. */ 12 banRkeys: Record<string, string>; 13 /** Post URI → rkey of its hide record on the sysop's PDS. */ 14 hideRkeys: Record<string, string>; 15} 16 17export async function fetchBBSModeration( 18 pdsUrl: string, 19 did: string, 20): Promise<BBSModeration> { 21 const [banRecs, hideRecs] = await Promise.all([ 22 listRecords(pdsUrl, did, BAN).catch(() => []), 23 listRecords(pdsUrl, did, HIDE).catch(() => []), 24 ]); 25 26 const banRkeys: Record<string, string> = {}; 27 for (const record of banRecs) { 28 if (!isBanRecord(record)) continue; 29 banRkeys[record.value.did] = parseAtUri(record.uri).rkey; 30 } 31 32 const hideRkeys: Record<string, string> = {}; 33 for (const record of hideRecs) { 34 if (!isHideRecord(record)) continue; 35 hideRkeys[record.value.uri] = parseAtUri(record.uri).rkey; 36 } 37 38 return { banRkeys, hideRkeys }; 39}