mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-25 00:04:22 +01:00
Move more Nostr schema stuff into schemas/nostr.ts
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user