···11+CREATE TABLE `labels_applied` (
22+ `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
33+ `did` text NOT NULL,
44+ `label` text NOT NULL,
55+ `action` text NOT NULL,
66+ `date_applied` integer NOT NULL,
77+ FOREIGN KEY (`did`) REFERENCES `watched_repos`(`did`) ON UPDATE no action ON DELETE no action
88+);
99+--> statement-breakpoint
1010+CREATE TABLE `watched_repos` (
1111+ `did` text PRIMARY KEY NOT NULL,
1212+ `pds_host` text NOT NULL,
1313+ `active` integer NOT NULL,
1414+ `date_first_seen` integer NOT NULL
1515+);
1616+--> statement-breakpoint
1717+CREATE UNIQUE INDEX `watched_repos_did_unique` ON `watched_repos` (`did`);
···11+#I'm hoping this is the parent?
22+[lavel-watcher.settings]
33+pds=['selfhosted.social']
44+55+#I'm hoping this is another parent?
66+[labeler.skywatch]
77+host="ozone.skywatch.blue"
88+99+# I'm hoping there will be multiple ones
1010+[labeler.skywatch.test-label]
1111+label_name="test-label"
1212+action="notify"
+11
src/db/index.ts
···11+import { drizzle } from "drizzle-orm/libsql";
22+import { createClient } from "@libsql/client";
33+import * as schema from "./schema.js";
44+55+const authToken = process.env["DATABASE_AUTH_TOKEN"];
66+const client = createClient({
77+ url: process.env.DATABASE_URL ?? "file:./label-watcher.db",
88+ ...(authToken !== undefined && { authToken }),
99+});
1010+1111+export const db = drizzle(client, { schema });
···11import { FirehoseSubscription } from "@atcute/firehose";
22import { ComAtprotoLabelSubscribeLabels } from "@atcute/atproto";
33+import { db } from "./db/index.js";
44+import { migrate } from "drizzle-orm/libsql/migrator";
55+66+// TODO
77+// 1. Figure out a schema for settings we want. PDSs to watch.Labelers and their Labels
88+// and which actions to do for them (notification/email) or auto takedown. thinking toml file maybe?
99+// 2. Add a CLI argument to backfill PDS repos on start up. If finds a new active repo adds it
1010+// 3. Add a firehose listner that subsribes to the PDSs for new identies? (I say maybe not cause of bandwidth)
1111+1212+// Run Drizzle migrations on startup
1313+migrate(db, { migrationsFolder: process.env.MIGRATIONS_FOLDER ?? "drizzle" });
314415const listner = async (id: string, wss: string) => {
516 const subscription = new FirehoseSubscription({