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

Some more error handling

+22 -13
+18 -13
src/handlers/handleNewIdentityEvent.ts
··· 1 1 import * as schema from "../db/schema.js"; 2 2 import type { LibSQLDatabase } from "drizzle-orm/libsql"; 3 + import { logger } from "../logger.js"; 3 4 4 5 export const handleNewIdentityEvent = async ( 5 6 db: LibSQLDatabase<typeof schema>, ··· 7 8 did: string, 8 9 active: boolean, 9 10 ) => { 10 - await db 11 - .insert(schema.watchedRepos) 12 - .values({ 13 - did, 14 - pdsHost, 15 - active, 16 - dateFirstSeen: new Date(), 17 - }) 18 - .onConflictDoUpdate({ 19 - target: schema.watchedRepos.did, 20 - set: { 11 + try { 12 + await db 13 + .insert(schema.watchedRepos) 14 + .values({ 15 + did, 21 16 pdsHost, 22 17 active, 23 - }, 24 - }); 18 + dateFirstSeen: new Date(), 19 + }) 20 + .onConflictDoUpdate({ 21 + target: schema.watchedRepos.did, 22 + set: { 23 + pdsHost, 24 + active, 25 + }, 26 + }); 27 + } catch (error) { 28 + logger.error({ error }, "Error handling new identity event"); 29 + } 25 30 };
+4
src/handlers/handleNewLabel.ts
··· 22 22 //TODO need to pass on the full url later for logging to the db and notifiation 23 23 let atUriSplit = label.uri.split("/"); 24 24 let repoDid = atUriSplit[2]; 25 + if (repoDid === undefined) { 26 + throw new Error(`Invalid URI: ${label.uri}`); 27 + } 28 + targetDid = repoDid; 25 29 } 26 30 27 31 // TODO: MAKE SURE TO CHECK NEG