diff --git a/src/schema.ts b/src/schema.ts index a29191f4..8868cca2 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -21,9 +21,6 @@ const jsonSchema = z.string().transform((value, ctx) => { } }); -/** Parses a Nostr emoji tag. */ -const emojiTagSchema = z.tuple([z.literal('emoji'), z.string(), z.string().url()]); - /** https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem */ const decode64Schema = z.string().transform((value, ctx) => { try { @@ -51,13 +48,4 @@ const booleanParamSchema = z.enum(['true', 'false']).transform((value) => value /** Schema for `File` objects. */ const fileSchema = z.custom((value) => value instanceof File); -export { - booleanParamSchema, - decode64Schema, - emojiTagSchema, - fileSchema, - filteredArray, - hashtagSchema, - jsonSchema, - safeUrlSchema, -}; +export { booleanParamSchema, decode64Schema, fileSchema, filteredArray, hashtagSchema, jsonSchema, safeUrlSchema }; diff --git a/src/schemas/nostr.ts b/src/schemas/nostr.ts index c097935c..7fb888c7 100644 --- a/src/schemas/nostr.ts +++ b/src/schemas/nostr.ts @@ -111,6 +111,12 @@ const connectResponseSchema = z.object({ result: signedEventSchema, }); +/** Parses a Nostr emoji tag. */ +const emojiTagSchema = z.tuple([z.literal('emoji'), z.string(), z.string().url()]); + +/** NIP-30 custom emoji tag. */ +type EmojiTag = z.infer; + export { type ClientCLOSE, type ClientCOUNT, @@ -119,6 +125,8 @@ export { clientMsgSchema, type ClientREQ, connectResponseSchema, + type EmojiTag, + emojiTagSchema, filterSchema, jsonMediaDataSchema, jsonMetaContentSchema, diff --git a/src/views/nostr-to-mastoapi.ts b/src/views/nostr-to-mastoapi.ts index 1e3b887d..e7af4684 100644 --- a/src/views/nostr-to-mastoapi.ts +++ b/src/views/nostr-to-mastoapi.ts @@ -5,8 +5,8 @@ import * as eventsDB from '@/db/events.ts'; import { type Event, findReplyTag, lodash, nip19, sanitizeHtml, TTLCache, unfurl, type UnsignedEvent } from '@/deps.ts'; import { getMediaLinks, parseNoteContent } from '@/note.ts'; import { getAuthor, getFollowedPubkeys, getFollows } from '@/queries.ts'; -import { emojiTagSchema, filteredArray } from '@/schema.ts'; -import { jsonMediaDataSchema, jsonMetaContentSchema } from '@/schemas/nostr.ts'; +import { filteredArray } from '@/schema.ts'; +import { emojiTagSchema, jsonMediaDataSchema, jsonMetaContentSchema } from '@/schemas/nostr.ts'; import { isFollowing, type Nip05, nostrDate, nostrNow, parseNip05, Time } from '@/utils.ts'; import { verifyNip05Cached } from '@/utils/nip05.ts'; import { findUser } from '@/db/users.ts';