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 { type Event, type SignedEvent } from '@/event.ts';
import { poolRelays } from './config.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>[]> { async function getAncestors(event: Event<1>, result = [] as Event<1>[]): Promise<Event<1>[]> {
if (result.length < 100) { if (result.length < 100) {
const replyTag = event.tags const replyTag = findReplyTag(event);
.find((t) => t[0] === 'e' && (!t[2] || t[2] === 'reply' || t[2] === 'root'));
const inReplyTo = replyTag ? replyTag[1] : undefined; const inReplyTo = replyTag ? replyTag[1] : undefined;
if (inReplyTo) { if (inReplyTo) {

View File

@ -20,3 +20,4 @@ export {
nip21, nip21,
signEvent as getSignature, signEvent as getSignature,
} from 'npm:nostr-tools@^1.10.1'; } 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 Event } from '@/event.ts';
import { type MetaContent, parseContent } from '@/schema.ts'; import { type MetaContent, parseContent } from '@/schema.ts';
@ -73,8 +73,7 @@ async function toStatus(event: Event<1>) {
const account = profile ? toAccount(profile) : undefined; const account = profile ? toAccount(profile) : undefined;
if (!account) return; if (!account) return;
const inReplyTo = event.tags const replyTag = findReplyTag(event);
.find((tag) => tag[0] === 'e' && (!tag[3] || tag[3] === 'reply' || tag[3] === 'root'));
const mentionedPubkeys = [ const mentionedPubkeys = [
...new Set( ...new Set(
@ -89,7 +88,7 @@ async function toStatus(event: Event<1>) {
account, account,
content: event.content, content: event.content,
created_at: new Date(event.created_at * 1000).toISOString(), 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, in_reply_to_account_id: null,
sensitive: false, sensitive: false,
spoiler_text: '', spoiler_text: '',