From 26cf528fcad709e53129bc7978f93ef9b3de03fa Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 29 Apr 2023 20:33:52 -0500 Subject: [PATCH] Use findReplyTag from Mostr --- src/client.ts | 6 ++---- src/deps.ts | 1 + src/transmute.ts | 7 +++---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/client.ts b/src/client.ts index 66ff669..374612f 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,4 +1,4 @@ -import { Author, type Filter, matchFilter, RelayPool } from '@/deps.ts'; +import { Author, type Filter, findReplyTag, matchFilter, RelayPool } from '@/deps.ts'; import { type Event, type SignedEvent } from '@/event.ts'; import { poolRelays } from './config.ts'; @@ -99,9 +99,7 @@ function getFeed(event3: Event<3>, params: PaginationParams = {}): Promise, result = [] as Event<1>[]): Promise[]> { if (result.length < 100) { - const replyTag = event.tags - .find((t) => t[0] === 'e' && (!t[2] || t[2] === 'reply' || t[2] === 'root')); - + const replyTag = findReplyTag(event); const inReplyTo = replyTag ? replyTag[1] : undefined; if (inReplyTo) { diff --git a/src/deps.ts b/src/deps.ts index f52b576..08eab05 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -20,3 +20,4 @@ export { nip21, signEvent as getSignature, } from 'npm:nostr-tools@^1.10.1'; +export { findReplyTag } from 'https://gitlab.com/soapbox-pub/mostr/-/raw/c67064aee5ade5e01597c6d23e22e53c628ef0e2/src/nostr/tags.ts'; diff --git a/src/transmute.ts b/src/transmute.ts index 3179325..271ed4d 100644 --- a/src/transmute.ts +++ b/src/transmute.ts @@ -1,4 +1,4 @@ -import { nip19 } from '@/deps.ts'; +import { findReplyTag, nip19 } from '@/deps.ts'; import { type Event } from '@/event.ts'; import { type MetaContent, parseContent } from '@/schema.ts'; @@ -73,8 +73,7 @@ async function toStatus(event: Event<1>) { const account = profile ? toAccount(profile) : undefined; if (!account) return; - const inReplyTo = event.tags - .find((tag) => tag[0] === 'e' && (!tag[3] || tag[3] === 'reply' || tag[3] === 'root')); + const replyTag = findReplyTag(event); const mentionedPubkeys = [ ...new Set( @@ -89,7 +88,7 @@ async function toStatus(event: Event<1>) { account, content: event.content, created_at: new Date(event.created_at * 1000).toISOString(), - in_reply_to_id: inReplyTo ? inReplyTo[1] : null, + in_reply_to_id: replyTag ? replyTag[1] : null, in_reply_to_account_id: null, sensitive: false, spoiler_text: '',