From 8ac5173d5b4fbacdeb28476319cddfef49361e41 Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Wed, 6 Mar 2024 09:07:28 -0800 Subject: [PATCH] improve parent hints --- src/util/Events.ts | 3 +++ src/util/Router.ts | 2 ++ src/util/Tags.ts | 4 ++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/util/Events.ts b/src/util/Events.ts index 12b3bce..7860097 100644 --- a/src/util/Events.ts +++ b/src/util/Events.ts @@ -25,6 +25,9 @@ export const asUnsignedEvent = ({kind, tags, content, created_at, pubkey}: Unsig export const asRumor = ({kind, tags, content, created_at, pubkey, id}: Rumor): Rumor => ({kind, tags, content, created_at, pubkey, id}) +export const asEvent = ({kind, tags, content, created_at, pubkey, id, sig}: Event): Event => + ({kind, tags, content, created_at, pubkey, id, sig}) + export const hasValidSignature = cached({ maxSize: 10000, getKey: ([e]: [Event]) => { diff --git a/src/util/Router.ts b/src/util/Router.ts index 8e2431f..3a43281 100644 --- a/src/util/Router.ts +++ b/src/util/Router.ts @@ -122,6 +122,7 @@ export class Router { return this.scenario([ tags.replies().relays().valueOf(), + tags.roots().relays().valueOf(), ...this.getContextRelayGroups(event), ...tags.whereKey("p").values().valueOf() .map(pk => this.options.getPubkeyRelays(pk, RelayMode.Outbox)), @@ -135,6 +136,7 @@ export class Router { return this.scenario([ tags.roots().relays().valueOf(), + tags.replies().relays().valueOf(), ...this.getContextRelayGroups(event), ...tags.whereKey("p").values().valueOf() .map(pk => this.options.getPubkeyRelays(pk, RelayMode.Outbox)), diff --git a/src/util/Tags.ts b/src/util/Tags.ts index 89b7e7b..e24d5f6 100644 --- a/src/util/Tags.ts +++ b/src/util/Tags.ts @@ -2,7 +2,7 @@ import {EventTemplate} from 'nostr-tools' import {Fluent} from './Fluent' import type {OmitStatics} from './Tools' import {last} from './Tools' -import {isShareableRelayUrl} from './Relays' +import {isShareableRelayUrl, normalizeRelayUrl} from './Relays' import type {Address} from './Address' import {encodeAddress, decodeAddress} from './Address' import {GROUP_DEFINITION, COMMUNITY_DEFINITION} from './Kinds' @@ -79,7 +79,7 @@ export class Tags extends (Fluent as OmitStatics, 'from' entries = () => this.mapTo(t => t.entry()) - relays = () => this.flatMap((t: Tag) => t.valueOf().filter(isShareableRelayUrl)).uniq() + relays = () => this.flatMap((t: Tag) => t.valueOf().filter(isShareableRelayUrl).map(normalizeRelayUrl)).uniq() topics = () => this.whereKey("t").values().map((t: string) => t.replace(/^#/, ""))