loopback: use RelayPool instead of nostr-tools just because it doesn't die so often

This commit is contained in:
Alex Gleason 2023-07-26 12:54:06 -05:00
parent 7eedeef2b4
commit 14e60048a6
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 9 additions and 7 deletions

View File

@ -20,7 +20,6 @@ export {
nip05, nip05,
nip19, nip19,
nip21, nip21,
relayInit,
verifySignature, verifySignature,
} from 'npm:nostr-tools@^1.11.2'; } from 'npm:nostr-tools@^1.11.2';
export { findReplyTag } from 'https://gitlab.com/soapbox-pub/mostr/-/raw/c67064aee5ade5e01597c6d23e22e53c628ef0e2/src/nostr/tags.ts'; export { findReplyTag } from 'https://gitlab.com/soapbox-pub/mostr/-/raw/c67064aee5ade5e01597c6d23e22e53c628ef0e2/src/nostr/tags.ts';

View File

@ -1,19 +1,22 @@
import { Conf } from '@/config.ts'; import { Conf } from '@/config.ts';
import { relayInit } from '@/deps.ts'; import { RelayPool } from '@/deps.ts';
import { trends } from '@/trends.ts'; import { trends } from '@/trends.ts';
import { nostrDate, nostrNow } from '@/utils.ts'; import { nostrDate, nostrNow } from '@/utils.ts';
import type { Event } from '@/event.ts'; import type { Event } from '@/event.ts';
const relay = relayInit(Conf.relay); const relay = new RelayPool([Conf.relay]);
await relay.connect();
// This file watches all events on your Ditto relay and triggers // This file watches all events on your Ditto relay and triggers
// side-effects based on them. This can be used for things like // side-effects based on them. This can be used for things like
// notifications, trending hashtag tracking, etc. // notifications, trending hashtag tracking, etc.
relay relay.subscribe(
.sub([{ kinds: [1], since: nostrNow() }]) [{ kinds: [1], since: nostrNow() }],
.on('event', handleEvent); [Conf.relay],
handleEvent,
undefined,
undefined,
);
/** Handle events through the loopback pipeline. */ /** Handle events through the loopback pipeline. */
function handleEvent(event: Event): void { function handleEvent(event: Event): void {