From e999d693d0dcc21eb525c628d2d17bb8e510aad7 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 12 Aug 2023 11:48:49 -0500 Subject: [PATCH] Rename hexIdSchema back to nostrIdSchema --- src/schemas/nostr.ts | 12 ++++++------ src/trends.ts | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/schemas/nostr.ts b/src/schemas/nostr.ts index 56bd276..4c0d17b 100644 --- a/src/schemas/nostr.ts +++ b/src/schemas/nostr.ts @@ -3,16 +3,16 @@ import { verifySignature, z } from '@/deps.ts'; import { jsonSchema } from '../schema.ts'; /** Schema to validate Nostr hex IDs such as event IDs and pubkeys. */ -const hexIdSchema = z.string().regex(/^[0-9a-f]{64}$/); +const nostrIdSchema = z.string().regex(/^[0-9a-f]{64}$/); /** Nostr event schema. */ const eventSchema = z.object({ - id: hexIdSchema, + id: nostrIdSchema, kind: z.number(), tags: z.array(z.array(z.string())), content: z.string(), created_at: z.number(), - pubkey: hexIdSchema, + pubkey: nostrIdSchema, sig: z.string(), }); @@ -22,8 +22,8 @@ const signedEventSchema = eventSchema.refine(verifySignature); /** Nostr relay filter schema. */ const filterSchema = z.object({ kinds: z.number().int().positive().array().optional(), - ids: hexIdSchema.array().optional(), - authors: hexIdSchema.array().optional(), + ids: nostrIdSchema.array().optional(), + authors: nostrIdSchema.array().optional(), since: z.number().int().positive().optional(), until: z.number().int().positive().optional(), limit: z.number().int().positive().optional(), @@ -58,9 +58,9 @@ type MetaContent = z.infer; export { clientMsgSchema, filterSchema, - hexIdSchema, jsonMetaContentSchema, type MetaContent, metaContentSchema, + nostrIdSchema, signedEventSchema, }; diff --git a/src/trends.ts b/src/trends.ts index aa1ea2d..a97b2c2 100644 --- a/src/trends.ts +++ b/src/trends.ts @@ -1,6 +1,6 @@ import { Sqlite } from '@/deps.ts'; import { hashtagSchema } from '@/schema.ts'; -import { hexIdSchema } from '@/schemas/nostr.ts'; +import { nostrIdSchema } from '@/schemas/nostr.ts'; import { Time } from '@/utils.ts'; import { generateDateRange } from '@/utils/time.ts'; @@ -101,7 +101,7 @@ class TrendsDB { } addTagUsages(pubkey: string, hashtags: string[], date = new Date()): void { - const pubkey8 = hexIdSchema.parse(pubkey).substring(0, 8); + const pubkey8 = nostrIdSchema.parse(pubkey).substring(0, 8); const tags = hashtagSchema.array().min(1).parse(hashtags); this.#db.query(