Move emojiTagSchema into schemas/nostr.ts

This commit is contained in:
Alex Gleason 2023-10-06 12:39:22 -05:00
parent 9ca3ec08a3
commit db17f84937
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
3 changed files with 11 additions and 15 deletions

View File

@ -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 */ /** https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem */
const decode64Schema = z.string().transform((value, ctx) => { const decode64Schema = z.string().transform((value, ctx) => {
try { try {
@ -51,13 +48,4 @@ const booleanParamSchema = z.enum(['true', 'false']).transform((value) => value
/** Schema for `File` objects. */ /** Schema for `File` objects. */
const fileSchema = z.custom<File>((value) => value instanceof File); const fileSchema = z.custom<File>((value) => value instanceof File);
export { export { booleanParamSchema, decode64Schema, fileSchema, filteredArray, hashtagSchema, jsonSchema, safeUrlSchema };
booleanParamSchema,
decode64Schema,
emojiTagSchema,
fileSchema,
filteredArray,
hashtagSchema,
jsonSchema,
safeUrlSchema,
};

View File

@ -111,6 +111,12 @@ const connectResponseSchema = z.object({
result: signedEventSchema, 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<typeof emojiTagSchema>;
export { export {
type ClientCLOSE, type ClientCLOSE,
type ClientCOUNT, type ClientCOUNT,
@ -119,6 +125,8 @@ export {
clientMsgSchema, clientMsgSchema,
type ClientREQ, type ClientREQ,
connectResponseSchema, connectResponseSchema,
type EmojiTag,
emojiTagSchema,
filterSchema, filterSchema,
jsonMediaDataSchema, jsonMediaDataSchema,
jsonMetaContentSchema, jsonMetaContentSchema,

View File

@ -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 { type Event, findReplyTag, lodash, nip19, sanitizeHtml, TTLCache, unfurl, type UnsignedEvent } from '@/deps.ts';
import { getMediaLinks, parseNoteContent } from '@/note.ts'; import { getMediaLinks, parseNoteContent } from '@/note.ts';
import { getAuthor, getFollowedPubkeys, getFollows } from '@/queries.ts'; import { getAuthor, getFollowedPubkeys, getFollows } from '@/queries.ts';
import { emojiTagSchema, filteredArray } from '@/schema.ts'; import { filteredArray } from '@/schema.ts';
import { jsonMediaDataSchema, jsonMetaContentSchema } from '@/schemas/nostr.ts'; import { emojiTagSchema, jsonMediaDataSchema, jsonMetaContentSchema } from '@/schemas/nostr.ts';
import { isFollowing, type Nip05, nostrDate, nostrNow, parseNip05, Time } from '@/utils.ts'; import { isFollowing, type Nip05, nostrDate, nostrNow, parseNip05, Time } from '@/utils.ts';
import { verifyNip05Cached } from '@/utils/nip05.ts'; import { verifyNip05Cached } from '@/utils/nip05.ts';
import { findUser } from '@/db/users.ts'; import { findUser } from '@/db/users.ts';