Rename hexIdSchema back to nostrIdSchema
This commit is contained in:
parent
80775d8bf0
commit
e999d693d0
|
@ -3,16 +3,16 @@ import { verifySignature, z } from '@/deps.ts';
|
||||||
import { jsonSchema } from '../schema.ts';
|
import { jsonSchema } from '../schema.ts';
|
||||||
|
|
||||||
/** Schema to validate Nostr hex IDs such as event IDs and pubkeys. */
|
/** 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. */
|
/** Nostr event schema. */
|
||||||
const eventSchema = z.object({
|
const eventSchema = z.object({
|
||||||
id: hexIdSchema,
|
id: nostrIdSchema,
|
||||||
kind: z.number(),
|
kind: z.number(),
|
||||||
tags: z.array(z.array(z.string())),
|
tags: z.array(z.array(z.string())),
|
||||||
content: z.string(),
|
content: z.string(),
|
||||||
created_at: z.number(),
|
created_at: z.number(),
|
||||||
pubkey: hexIdSchema,
|
pubkey: nostrIdSchema,
|
||||||
sig: z.string(),
|
sig: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@ const signedEventSchema = eventSchema.refine(verifySignature);
|
||||||
/** Nostr relay filter schema. */
|
/** Nostr relay filter schema. */
|
||||||
const filterSchema = z.object({
|
const filterSchema = z.object({
|
||||||
kinds: z.number().int().positive().array().optional(),
|
kinds: z.number().int().positive().array().optional(),
|
||||||
ids: hexIdSchema.array().optional(),
|
ids: nostrIdSchema.array().optional(),
|
||||||
authors: hexIdSchema.array().optional(),
|
authors: nostrIdSchema.array().optional(),
|
||||||
since: z.number().int().positive().optional(),
|
since: z.number().int().positive().optional(),
|
||||||
until: z.number().int().positive().optional(),
|
until: z.number().int().positive().optional(),
|
||||||
limit: z.number().int().positive().optional(),
|
limit: z.number().int().positive().optional(),
|
||||||
|
@ -58,9 +58,9 @@ type MetaContent = z.infer<typeof metaContentSchema>;
|
||||||
export {
|
export {
|
||||||
clientMsgSchema,
|
clientMsgSchema,
|
||||||
filterSchema,
|
filterSchema,
|
||||||
hexIdSchema,
|
|
||||||
jsonMetaContentSchema,
|
jsonMetaContentSchema,
|
||||||
type MetaContent,
|
type MetaContent,
|
||||||
metaContentSchema,
|
metaContentSchema,
|
||||||
|
nostrIdSchema,
|
||||||
signedEventSchema,
|
signedEventSchema,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Sqlite } from '@/deps.ts';
|
import { Sqlite } from '@/deps.ts';
|
||||||
import { hashtagSchema } from '@/schema.ts';
|
import { hashtagSchema } from '@/schema.ts';
|
||||||
import { hexIdSchema } from '@/schemas/nostr.ts';
|
import { nostrIdSchema } from '@/schemas/nostr.ts';
|
||||||
import { Time } from '@/utils.ts';
|
import { Time } from '@/utils.ts';
|
||||||
import { generateDateRange } from '@/utils/time.ts';
|
import { generateDateRange } from '@/utils/time.ts';
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ class TrendsDB {
|
||||||
}
|
}
|
||||||
|
|
||||||
addTagUsages(pubkey: string, hashtags: string[], date = new Date()): void {
|
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);
|
const tags = hashtagSchema.array().min(1).parse(hashtags);
|
||||||
|
|
||||||
this.#db.query(
|
this.#db.query(
|
||||||
|
|
Loading…
Reference in New Issue