Delete src/nostr directory
This commit is contained in:
parent
b33a3a21fc
commit
6341987088
|
@ -1,6 +1,6 @@
|
|||
import { type AppContext } from '@/app.ts';
|
||||
import { validator, z } from '@/deps.ts';
|
||||
import { type Event } from '@/nostr/event.ts';
|
||||
import { type Event } from '@/event.ts';
|
||||
|
||||
import publish from '../publisher.ts';
|
||||
import { toStatus } from '../transmute.ts';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Author, RelayPool } from '@/deps.ts';
|
||||
import { type Event, type SignedEvent } from '@/nostr/event.ts';
|
||||
import { type Event, type SignedEvent } from '@/event.ts';
|
||||
|
||||
import { poolRelays } from './config.ts';
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { gossipDB } from '@/db.ts';
|
||||
import { type Event } from '@/nostr/event.ts';
|
||||
import { type Event } from '@/event.ts';
|
||||
|
||||
import { getAuthorRelays } from './gossip.ts';
|
||||
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
import { z } from '@/deps.ts';
|
||||
|
||||
import { type Event } from '../event.ts';
|
||||
|
||||
const optionalString = z.string().optional().catch(undefined);
|
||||
|
||||
const metaContentSchema = z.object({
|
||||
name: optionalString,
|
||||
about: optionalString,
|
||||
picture: optionalString,
|
||||
banner: optionalString,
|
||||
nip05: optionalString,
|
||||
lud16: optionalString,
|
||||
});
|
||||
|
||||
/** Author metadata from Event<0>. */
|
||||
type MetaContent = z.infer<typeof metaContentSchema>;
|
||||
|
||||
/**
|
||||
* Get (and validate) data from a kind 0 event.
|
||||
* https://github.com/nostr-protocol/nips/blob/master/01.md
|
||||
*/
|
||||
function parseContent(event: Event<0>): MetaContent {
|
||||
try {
|
||||
const json = JSON.parse(event.content);
|
||||
return metaContentSchema.parse(json);
|
||||
} catch (_e) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
export { type MetaContent, metaContentSchema, parseContent };
|
|
@ -1,5 +1,5 @@
|
|||
import { getEventHash, getSignature } from '@/deps.ts';
|
||||
import { type Event } from '@/nostr/event.ts';
|
||||
import { type Event } from '@/event.ts';
|
||||
|
||||
import { pool } from './client.ts';
|
||||
import { publishRelays } from './config.ts';
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
import { z } from '@/deps.ts';
|
||||
|
||||
import type { Event } from './event.ts';
|
||||
|
||||
const optionalString = z.string().optional().catch(undefined);
|
||||
|
||||
const jsonSchema = z.string().transform((value, ctx) => {
|
||||
try {
|
||||
return JSON.parse(value);
|
||||
|
@ -9,6 +13,33 @@ const jsonSchema = z.string().transform((value, ctx) => {
|
|||
}
|
||||
});
|
||||
|
||||
const metaContentSchema = z.object({
|
||||
name: optionalString,
|
||||
about: optionalString,
|
||||
picture: optionalString,
|
||||
banner: optionalString,
|
||||
nip05: optionalString,
|
||||
lud16: optionalString,
|
||||
});
|
||||
|
||||
/** Author metadata from Event<0>. */
|
||||
type MetaContent = z.infer<typeof metaContentSchema>;
|
||||
|
||||
/**
|
||||
* Get (and validate) data from a kind 0 event.
|
||||
* https://github.com/nostr-protocol/nips/blob/master/01.md
|
||||
*/
|
||||
function parseContent(event: Event<0>): MetaContent {
|
||||
try {
|
||||
const json = JSON.parse(event.content);
|
||||
return metaContentSchema.parse(json);
|
||||
} catch (_e) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
export { type MetaContent, metaContentSchema, parseContent };
|
||||
|
||||
/** Alias for `safeParse`, but instead of returning a success object it returns the value (or undefined on fail). */
|
||||
function parseValue<T>(schema: z.ZodType<T>, value: unknown): T | undefined {
|
||||
const result = schema.safeParse(value);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { nip19 } from '@/deps.ts';
|
||||
import { type Event } from '@/nostr/event.ts';
|
||||
import { type MetaContent, parseContent } from '@/nostr/events/kind-0.ts';
|
||||
import { type Event } from '@/event.ts';
|
||||
import { type MetaContent, parseContent } from '@/schema.ts';
|
||||
|
||||
import { LOCAL_DOMAIN } from './config.ts';
|
||||
import { fetchUser } from './client.ts';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Context, getPublicKey } from '@/deps.ts';
|
||||
import { type Event } from '@/nostr/event.ts';
|
||||
import { type Event } from '@/event.ts';
|
||||
|
||||
/** Get the current time in Nostr format. */
|
||||
const nostrNow = () => Math.floor(new Date().getTime() / 1000);
|
||||
|
|
Loading…
Reference in New Issue