fix: replies

This commit is contained in:
codytseng 2025-05-15 23:38:22 +08:00
parent a6c2decfe3
commit 304bbe4f01
13 changed files with 178 additions and 120 deletions

View file

@ -1,6 +1,7 @@
import client from '@/services/client.service'
import { TImageInfo } from '@/types'
import { isBlurhashValid } from 'blurhash'
import { nip19 } from 'nostr-tools'
import { Event, nip19 } from 'nostr-tools'
import { isValidPubkey } from './pubkey'
export function tagNameEquals(tagName: string) {
@ -28,6 +29,11 @@ export function generateEventIdFromETag(tag: string[]) {
}
}
export function generateEventId(event: Pick<Event, 'id' | 'pubkey'>) {
const relay = client.getEventHint(event.id)
return nip19.neventEncode({ id: event.id, author: event.pubkey, relays: [relay] })
}
export function extractImageInfoFromTag(tag: string[]): TImageInfo | null {
if (tag[0] !== 'imeta') return null
const urlItem = tag.find((item) => item.startsWith('url '))