2026-01-13 14:49:19 +01:00

19 lines
992 B
TypeScript

import type { Event } from 'nostr-tools'
import { extractTagsFromEvent } from '../nostrTagSystem'
import { buildObjectId } from '../urlGenerator'
import { readPresentationProfileData } from './profileData'
import { mapTagCategoryToOriginalCategory, resolvePresentationIdParts } from './idResolution'
import { buildPresentationArticle } from './articleBuilder'
export async function parsePresentationEvent(event: Event): Promise<import('@/types/nostr').AuthorPresentationArticle | null> {
const tags = extractTagsFromEvent(event)
if (tags.type !== 'author') {
return null
}
const profileData = readPresentationProfileData(tags.json, event.content)
const originalCategory = mapTagCategoryToOriginalCategory(tags.category)
const { hash, version, index } = await resolvePresentationIdParts({ tags, event, profileData })
const id = buildObjectId(hash, index, version)
return buildPresentationArticle({ id, hash, version, index, event, tags, profileData, originalCategory })
}