import { Relay } from 'applesauce-relay' import { PrivateKeySigner } from 'applesauce-signers/signers/private-key-signer' import { TEST_PERSONAS, TASTEMAKER_PERSONAS, } from '../src/data/testPersonas.js' const RELAY_URL = process.env.RELAY_URL || 'ws://localhost:7777' type Persona = { name: string; nsec: string; pubkey: string } function buildProfile(persona: Persona, role: 'test' | 'tastemaker') { const about = role === 'tastemaker' ? `${persona.name} — tastemaker for IndeeHub` : `${persona.name} — test persona for IndeeHub` return { name: persona.name, display_name: persona.name, about, picture: `https://robohash.org/${persona.pubkey}.png`, bot: true, } } async function seedProfiles() { const relay = new Relay(RELAY_URL) const allPersonas: { persona: Persona; role: 'test' | 'tastemaker' }[] = [ ...TEST_PERSONAS.map((p) => ({ persona: p as Persona, role: 'test' as const })), ...TASTEMAKER_PERSONAS.map((p) => ({ persona: p as Persona, role: 'tastemaker' as const })), ] const now = Math.floor(Date.now() / 1000) for (const { persona, role } of allPersonas) { const signer = PrivateKeySigner.fromKey(persona.nsec) const profile = buildProfile(persona, role) const signed = await signer.signEvent({ kind: 0, created_at: now, tags: [], content: JSON.stringify(profile), }) try { const res = await relay.publish(signed, { timeout: 5000 }) console.log(`✓ ${persona.name} (${role}): ${res.ok ? 'OK' : res.message}`) } catch (err) { console.error(`✗ ${persona.name} (${role}):`, err) } } // Give relay time to flush, then exit setTimeout(() => process.exit(0), 1000) } seedProfiles().catch((err) => { console.error('Fatal:', err) process.exit(1) })