mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
28 lines
822 B
TypeScript
28 lines
822 B
TypeScript
import { getActiveRelays } from '@/db/relays.ts';
|
|
import { type Event, RelayPool } from '@/deps.ts';
|
|
import { nostrNow } from '@/utils.ts';
|
|
|
|
import * as pipeline from './pipeline.ts';
|
|
|
|
const relays = await getActiveRelays();
|
|
const pool = new RelayPool(relays);
|
|
|
|
// This file watches events on all known relays and performs
|
|
// side-effects based on them, such as trending hashtag tracking
|
|
// and storing events for notifications and the home feed.
|
|
pool.subscribe(
|
|
[{ kinds: [0, 1, 3, 5, 6, 7, 10002], limit: 0, since: nostrNow() }],
|
|
relays,
|
|
handleEvent,
|
|
undefined,
|
|
undefined,
|
|
);
|
|
|
|
/** Handle events through the firehose pipeline. */
|
|
function handleEvent(event: Event): Promise<void> {
|
|
console.info(`firehose: Event<${event.kind}> ${event.id}`);
|
|
|
|
return pipeline
|
|
.handleEvent(event)
|
|
.catch(() => {});
|
|
}
|