PDS Admin tool make it easier to moderate your PDS with labels
43
fork

Configure Feed

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

Are you silly. ofcourse I'm going to send it

+70 -17
+1 -2
.env.example
··· 1 1 DATABASE_URL=file:./label-watcher.db 2 2 MIGRATIONS_FOLDER=drizzle 3 - NOTIFY_SMTP_URL=smtps://resend:.... 3 + NOTIFY_SMTP_URL=smtp://localhost:1025 4 4 NOTIFY_SENDER_EMAIL=yougotmail@pdsmoover.com 5 - NOTIFY_RECIPIENT_EMAILS=you@example.com,other@example.com 6 5 LOG_LEVEL=info
+42
README.md
··· 1 + # Label Watcher 2 + 3 + >WIP: Will share with a few people, and ofc it's public if you are reading this. But going run locally before telling the whole atmosphere about it and make a docker container 4 + 5 + 6 + Does what it says. Watches for labels. Okay really it watches for labelers and labels you set. And if it sees a label applied to an account on the PDS it notifies you via email. And will one day do auto take downs as well. 7 + 8 + The idea is we have some awesome labelers like [skywatch.blue](https://bsky.app/profile/skywatch.blue) and [Hailey's Labeler](https://bsky.app/profile/did:plc:saslbwamakedc4h6c5bmshvz) that are doing an amazing job of catching troubled accounts that PDS admins may want to know if they are doing these things on their PDS. This gives an easy way to use these resources to help moderate your PDS. And once auto takedowns are added I think it will be great for PDSs that also run their own labeler to be able to issue takedowns from a manual label added via ozone. 9 + 10 + 11 + 12 + 13 + 14 + # Setup 15 + Got some configs to setup. Use toml to set it up and have an example one at [settings.toml.example](./settings.toml.example). Here you can set 16 + - Which PDSs to follow 17 + - Which labelers and labels 18 + 19 + Also have a .env for some shared secrets at [.env.example](.env.example) 20 + 21 + 22 + Can use pnpm or npm and just do 23 + ```bash 24 + pnpm i 25 + pnpm run start 26 + ``` 27 + 28 + 29 + # Features 30 + 31 + ## PDS 32 + - Can backfill and get all active accounts on start up 33 + - Can listen to the PDSs firehose to add new identities as they are created on the PDS 34 + - Does not keep a cursor of the firehose during reboots since it can backfill on start up 35 + - Can set a list of emails to send notifications to of actions taken 36 + - Works for multiple PDSs configured in the settings.toml 37 + 38 + ## Labeler 39 + - Can subscribe to labels from a labeler. Multiple of each set up in the settings.toml 40 + - Does support backfilling of labels via the cursor on restart so you do not miss any 41 + - Will support full backfill at some point 42 + - Can give each label an action like notify or takedown (will come later). It will take the action and send you an email
+20 -14
settings.toml.example
··· 1 1 [label-watcher.settings] 2 - #PDSs to watch 3 - pds = ['selfhosted.social'] 2 + 3 + #PDSs to watch can have multiple ones 4 + [pds.your-pds] 5 + host = "your-pds.com" 6 + notifyEmails = ["admin@example.com", "another@example.com"] 7 + # Will be used for auto take downs on down the road 8 + pdsAdminPassword = "secure" 9 + # Loads all the historic accounts in 10 + backfillAccounts = true 11 + # Listens for new accounts 12 + listenForNewAccounts = true 4 13 5 - # Define the labeler 14 + 15 + # Define the labeler. Can do multiple labelers 6 16 [labeler.skywatch] 7 17 host = "ozone.skywatch.blue" 8 18 9 - # Can have multiple labels 10 - [labeler.skywatch.labels.test-label] 11 - label_name = "test-label" 19 + # Notifies if an account has elon musk in their description or display name 20 + [labeler.skywatch.labels.elon-musk] 21 + label_name = "elon-musk" 12 22 action = "notify" 13 23 14 - 15 - [labeler.bsky] 16 - host = "mod.bsky.app" 17 - 18 - # Can have multiple labels 19 - [labeler.bsky.labels.test-two] 20 - label_name = "test-two" 21 - action = "takedown" 24 + # Notifies if an account has the platform-manipulation label applied 25 + [labeler.skywatch.labels.platform-manipulation] 26 + label_name = "platform-manipulation" 27 + action = "notify"
+7 -1
src/handlers/handleNewLabel.ts
··· 31 31 const isRepoWatched = await db 32 32 .select() 33 33 .from(schema.watchedRepos) 34 - .where(eq(schema.watchedRepos.did, label.uri)) 34 + .where( 35 + and( 36 + eq(schema.watchedRepos.did, label.uri), 37 + eq(schema.watchedRepos.active, true), 38 + ), 39 + ) 35 40 .limit(1); 36 41 37 42 if (isRepoWatched.length > 0) { ··· 93 98 console.log(pdsConfig.notifyEmails); 94 99 await sendLabelNotification(pdsConfig.notifyEmails, { 95 100 did: label.uri, 101 + pds: pdsConfig.host, 96 102 label: label.val, 97 103 labeler: config.host, 98 104 negated: label.neg ?? false,