Move more Nostr schema stuff into schemas/nostr.ts

This commit is contained in:
Alex Gleason
2023-08-12 11:48:11 -05:00
parent 893542cf58
commit 80775d8bf0
5 changed files with 35 additions and 48 deletions

View File

@@ -1,5 +1,5 @@
import { Conf } from '@/config.ts';
import { parseMetaContent } from '@/schema.ts';
import { jsonMetaContentSchema } from '@/schemas/nostr.ts';
import { getPublicKeyPem } from '@/utils/rsa.ts';
import type { Event } from '@/event.ts';
@@ -7,7 +7,7 @@ import type { Actor } from '@/schemas/activitypub.ts';
/** Nostr metadata event to ActivityPub actor. */
async function toActor(event: Event<0>, username: string): Promise<Actor | undefined> {
const content = parseMetaContent(event);
const content = jsonMetaContentSchema.parse(event.content);
return {
type: 'Person',

View File

@@ -6,7 +6,8 @@ import { findReplyTag, lodash, nip19, sanitizeHtml, TTLCache, unfurl, z } from '
import { type Event } from '@/event.ts';
import { verifyNip05Cached } from '@/nip05.ts';
import { getMediaLinks, type MediaLink, parseNoteContent } from '@/note.ts';
import { emojiTagSchema, filteredArray, type MetaContent, parseMetaContent } from '@/schema.ts';
import { emojiTagSchema, filteredArray } from '@/schema.ts';
import { jsonMetaContentSchema } from '@/schemas/nostr.ts';
import { type Nip05, nostrDate, parseNip05, Time } from '@/utils.ts';
const DEFAULT_AVATAR = 'https://gleasonator.com/images/avi.png';
@@ -20,7 +21,7 @@ async function toAccount(event: Event<0>, opts: ToAccountOpts = {}) {
const { withSource = false } = opts;
const { pubkey } = event;
const { name, nip05, picture, banner, about }: MetaContent = parseMetaContent(event);
const { name, nip05, picture, banner, about } = jsonMetaContentSchema.parse(event.content);
const npub = nip19.npubEncode(pubkey);
let parsed05: Nip05 | undefined;