Use findReplyTag from Mostr

This commit is contained in:
Alex Gleason 2023-04-29 20:33:52 -05:00
parent b42d1f3564
commit 26cf528fca
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
3 changed files with 6 additions and 8 deletions

View File

@ -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<Signe
async function getAncestors(event: Event<1>, result = [] as Event<1>[]): Promise<Event<1>[]> {
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) {

View File

@ -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';

View File

@ -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: '',