Rename hexIdSchema back to nostrIdSchema

This commit is contained in:
Alex Gleason 2023-08-12 11:48:49 -05:00
parent 80775d8bf0
commit e999d693d0
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 8 additions and 8 deletions

View File

@ -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<typeof metaContentSchema>;
export {
clientMsgSchema,
filterSchema,
hexIdSchema,
jsonMetaContentSchema,
type MetaContent,
metaContentSchema,
nostrIdSchema,
signedEventSchema,
};

View File

@ -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(