Compare commits

...

4 commits

Author SHA1 Message Date
P. Reis
51642db93e Merge branch 'fix-duplicate-url' into 'main'
fix(createWalletSchema): get URL href

See merge request soapbox-pub/ditto!737
2025-06-04 09:34:37 -03:00
Alex Gleason
24d27c4cdd
Index I/i tags 2025-06-01 19:45:36 -05:00
Alex Gleason
96799d1918
Index kind 1111 tags 2025-06-01 14:45:29 -05:00
P. Reis
760fb1bb43 fix(createWalletSchema): get URL href 2025-05-08 19:24:56 -03:00
2 changed files with 21 additions and 8 deletions

View file

@ -151,10 +151,18 @@ route.post('/mint/:quote_id', userMiddleware({ enc: 'nip44' }), async (c) => {
}); });
const createWalletSchema = z.object({ const createWalletSchema = z.object({
mints: z.array(z.string().url()).nonempty().transform((val) => { mints: z.array(
z.string().url()
.transform((url) => new URL(url).href),
).nonempty()
.transform((val) => {
return [...new Set(val)]; return [...new Set(val)];
}), }),
relays: z.array(z.string().url()).transform((val) => { relays: z.array(
z.string().url()
.transform((url) => new URL(url).href),
)
.transform((val) => {
return [...new Set(val)]; return [...new Set(val)];
}), }),
}); });

View file

@ -80,15 +80,20 @@ export class DittoPgStore extends NPostgres {
/** Conditions for when to index certain tags. */ /** Conditions for when to index certain tags. */
static tagConditions: Record<string, TagCondition> = { static tagConditions: Record<string, TagCondition> = {
'A': ({ count }) => count === 0,
'E': ({ count, value }) => count === 0 && isNostrId(value),
'I': ({ count }) => count === 0,
'K': ({ count, value }) => count === 0 && Number.isInteger(Number(value)),
'L': ({ event, count }) => event.kind === 1985 || count === 0,
'P': ({ count, value }) => count === 0 && isNostrId(value),
'a': ({ count }) => count < 15, 'a': ({ count }) => count < 15,
'client': ({ count, value }) => count === 0 && value.length < 50, 'client': ({ count, value }) => count === 0 && value.length < 50,
'd': ({ event, count }) => count === 0 && NKinds.parameterizedReplaceable(event.kind), 'd': ({ event, count }) => count === 0 && NKinds.parameterizedReplaceable(event.kind),
'e': DittoPgStore.eTagCondition, 'e': DittoPgStore.eTagCondition,
'i': ({ count }) => count < 15,
'k': ({ count }) => count < 3, 'k': ({ count }) => count < 3,
'L': ({ event, count }) => event.kind === 1985 || count === 0,
'l': ({ event, count }) => event.kind === 1985 || count === 0, 'l': ({ event, count }) => event.kind === 1985 || count === 0,
'n': ({ count, value }) => count < 50 && value.length < 50, 'n': ({ count, value }) => count < 50 && value.length < 50,
'P': ({ count, value }) => count === 0 && isNostrId(value),
'p': DittoPgStore.pTagCondition, 'p': DittoPgStore.pTagCondition,
'proxy': ({ count, value }) => count === 0 && value.length < 256, 'proxy': ({ count, value }) => count === 0 && value.length < 256,
'q': ({ event, count, value }) => count === 0 && event.kind === 1 && isNostrId(value), 'q': ({ event, count, value }) => count === 0 && event.kind === 1 && isNostrId(value),