mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
21 lines
528 B
TypeScript
21 lines
528 B
TypeScript
import { Semaphore } from '@lambdalisue/async';
|
|
|
|
import * as pipeline from '@/pipeline.ts';
|
|
import { Storages } from '@/storages.ts';
|
|
|
|
const sem = new Semaphore(1);
|
|
|
|
export async function startNotify(): Promise<void> {
|
|
const { listen } = await Storages.database();
|
|
|
|
listen('nostr_event', (payload) => {
|
|
sem.lock(async () => {
|
|
try {
|
|
const event = JSON.parse(payload);
|
|
await pipeline.handleEvent(event, AbortSignal.timeout(5000));
|
|
} catch (e) {
|
|
console.warn(e);
|
|
}
|
|
});
|
|
});
|
|
}
|