this repo has no description
0
fork

Configure Feed

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

initial session work (do i even need this? who knows)

alice 6f0ed0ce 20dce5ec

+25 -2
+25 -2
src/server.ts
··· 9 9 import { FirehoseSubscription } from './subscription' 10 10 import { AppContext, Config } from './config' 11 11 import wellKnown from './well-known' 12 - import AtpAgent from '@atproto/api' 12 + import AtpAgent, { AtpSessionData, AtpSessionEvent } from '@atproto/api' 13 13 import * as process from 'node:process' 14 14 15 15 export class FeedGenerator { ··· 20 20 public cfg: Config 21 21 public agent: AtpAgent 22 22 public didResolver: DidResolver 23 + public session: string | null 23 24 24 25 constructor( 25 26 app: express.Application, ··· 67 68 68 69 async start(): Promise<http.Server> { 69 70 await migrateToLatest(this.db) 70 - this.agent = new AtpAgent({ service: 'https://bsky.social' }) 71 + this.agent = new AtpAgent({ 72 + service: 'https://bsky.social', 73 + persistSession: (evt: AtpSessionEvent, sess?: AtpSessionData) => { 74 + // store the session-data for reuse 75 + switch (evt) { 76 + case 'create': 77 + if (!sess) throw new Error('should be unreachable') 78 + this.session = JSON.stringify(sess) 79 + break 80 + case 'create-failed': 81 + this.session = null 82 + console.error('Could not create session') 83 + break 84 + case 'update': 85 + if (!sess) throw new Error('should be unreachable') 86 + this.session = JSON.stringify(sess) 87 + break 88 + case 'expired': 89 + this.session = null 90 + break 91 + } 92 + }, 93 + }) 71 94 await this.agent.login({ 72 95 identifier: process.env.HANDLE!, 73 96 password: process.env.PASSWORD!,