From 49fecd2291c28c4eb6ed672d000b39c1694582de Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Mon, 16 Jun 2025 08:40:35 -0700 Subject: [PATCH] Use getAncestorTags in router --- packages/router/src/index.ts | 7 ++----- packages/util/src/Events.ts | 5 ++++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/router/src/index.ts b/packages/router/src/index.ts index 8297216..728ec07 100644 --- a/packages/router/src/index.ts +++ b/packages/router/src/index.ts @@ -18,19 +18,17 @@ import { isOnionUrl, isLocalUrl, isShareableRelayUrl, - COMMENT, PROFILE, RELAYS, INBOX_RELAYS, FOLLOWS, WRAP, - getReplyTags, - getCommentTags, getPubkeyTagValues, normalizeRelayUrl, TrustedEvent, Filter, readList, + getAncestorTags, asDecryptedEvent, getRelaysFromList, RelayMode, @@ -215,8 +213,7 @@ export class Router { } EventAncestors = (event: TrustedEvent, type: "mentions" | "replies" | "roots") => { - const ancestorTags = - event.kind === COMMENT ? getCommentTags(event.tags) : getReplyTags(event.tags) + const ancestorTags = getAncestorTags(event) const tags: string[][] = (ancestorTags as any)[type] || [] diff --git a/packages/util/src/Events.ts b/packages/util/src/Events.ts index 2881038..a7d9656 100644 --- a/packages/util/src/Events.ts +++ b/packages/util/src/Events.ts @@ -2,7 +2,7 @@ import {verifiedSymbol, verifyEvent as verifyEventPure} from "nostr-tools/pure" import {setNostrWasm, verifyEvent as verifyEventWasm} from "nostr-tools/wasm" import {initNostrWasm} from "nostr-wasm" import {mapVals, first, pick, now} from "@welshman/lib" -import {getReplyTagValues, getCommentTagValues} from "./Tags.js" +import {getReplyTags, getCommentTags, getReplyTagValues, getCommentTagValues} from "./Tags.js" import {getAddress, Address} from "./Address.js" import { COMMENT, @@ -145,6 +145,9 @@ export const isPlainReplaceable = (e: EventTemplate) => isPlainReplaceableKind(e export const isParameterizedReplaceable = (e: EventTemplate) => isParameterizedReplaceableKind(e.kind) +export const getAncestorTags = ({kind, tags}: EventTemplate) => + kind === COMMENT ? getCommentTags(tags) : getReplyTags(tags) + export const getAncestors = ({kind, tags}: EventTemplate) => kind === COMMENT ? getCommentTagValues(tags) : getReplyTagValues(tags)