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.

Passes the config all the way down

+13 -7
+5 -2
src/handlers/handleNewLabel.ts
··· 39 39 if (watchedRepo == undefined) { 40 40 throw new Error(`Unexpected error on watched repo: ${label.uri}`); 41 41 } 42 - const pdsConfig = pdsConfigs[watchedRepo.pdsHost]; 42 + const pdsConfig = Object.values(pdsConfigs).find( 43 + (config) => config.host === watchedRepo.pdsHost, 44 + ); 43 45 if (pdsConfig == undefined) { 44 46 throw new Error(`Watched repo: ${watchedRepo.did} config not found`); 45 47 } ··· 88 90 89 91 // Perform action 90 92 if (labelConfig.action === "notify") { 91 - await sendLabelNotification(pdsConfig.emails, { 93 + console.log(pdsConfig.notifyEmails); 94 + await sendLabelNotification(pdsConfig.notifyEmails, { 92 95 did: label.uri, 93 96 label: label.val, 94 97 labeler: config.host,
+3 -2
src/handlers/lablerSubscriber.ts
··· 1 1 import { FirehoseSubscription } from "@atcute/firehose"; 2 - import type { LabelerConfig } from "../types/settings.js"; 2 + import type { LabelerConfig, PDSConfig } from "../types/settings.js"; 3 3 import { ComAtprotoLabelSubscribeLabels } from "@atcute/atproto"; 4 4 import type PQueue from "p-queue"; 5 5 import { handleNewLabel } from "./handleNewLabel.js"; ··· 13 13 lastCursor: number | undefined, 14 14 db: LibSQLDatabase<typeof schema>, 15 15 queue: PQueue, 16 + pdsConfigs: Record<string, PDSConfig>, 16 17 ): (() => void) => { 17 18 let cursor = lastCursor; 18 19 if (cursor) { ··· 51 52 // We only care about labels for identities, not content for now 52 53 if (label.uri.startsWith("did:")) { 53 54 queue.add(async () => { 54 - await handleNewLabel(config, label, db); 55 + await handleNewLabel(config, label, db, pdsConfigs); 55 56 }); 56 57 } 57 58 }
+1 -1
src/index.ts
··· 59 59 (cursor) => cursor.labelerId === config.host, 60 60 ); 61 61 let lastCursor = lastCursorRow?.cursor ?? undefined; 62 - return labelerSubscriber(config, lastCursor, db, labelQueue); 62 + return labelerSubscriber(config, lastCursor, db, labelQueue, settings.pds); 63 63 }) 64 64 .filter((x) => x !== null); 65 65
+3 -1
src/mailer.ts
··· 12 12 emails: string[], 13 13 params: { 14 14 did: string; 15 + pds: string; 15 16 label: string; 16 17 labeler: string; 17 18 negated: boolean; 18 19 dateApplied: Date; 19 20 }, 20 21 ) => { 21 - const { did, label, labeler, negated, dateApplied } = params; 22 + const { did, pds, label, labeler, negated, dateApplied } = params; 22 23 23 24 await transporter.sendMail({ 24 25 from: senderEmail, ··· 28 29 `A label event was detected.`, 29 30 ``, 30 31 `DID: ${did}`, 32 + `PDS: ${pds}`, 31 33 `Label: ${label}`, 32 34 `Labeler: ${labeler}`, 33 35 `Negated: ${negated}`,
+1 -1
src/types/settings.ts
··· 2 2 3 3 export interface PDSConfig { 4 4 host: string; 5 - emails: string[]; 5 + notifyEmails: string[]; 6 6 pdsAdminPassword: string; 7 7 backfillAccounts: boolean; 8 8 listenForNewAccounts: boolean;