feat: index 'u' tags

This commit is contained in:
P. Reis 2025-02-09 21:27:38 -03:00
parent af262b5d52
commit f85e7f7c33

View file

@ -6,6 +6,7 @@ import { logi } from '@soapbox/logi';
import { JsonValue } from '@std/json'; import { JsonValue } from '@std/json';
import { Kysely } from 'kysely'; import { Kysely } from 'kysely';
import { nip27 } from 'nostr-tools'; import { nip27 } from 'nostr-tools';
import { z } from 'zod';
import { DittoTables } from '@/db/DittoTables.ts'; import { DittoTables } from '@/db/DittoTables.ts';
import { dbEventsCounter } from '@/metrics.ts'; import { dbEventsCounter } from '@/metrics.ts';
@ -61,6 +62,10 @@ class EventsDB extends NPostgres {
'r': ({ event, count }) => (event.kind === 1985 ? count < 20 : count < 3), 'r': ({ event, count }) => (event.kind === 1985 ? count < 20 : count < 3),
't': ({ event, count, value }) => 't': ({ event, count, value }) =>
(value === value.toLowerCase()) && (event.kind === 1985 ? count < 20 : count < 5) && value.length < 50, (value === value.toLowerCase()) && (event.kind === 1985 ? count < 20 : count < 5) && value.length < 50,
'u': ({ count, value }) => {
const { success } = z.string().url().safeParse(value); // maybe find a better library specific for validating web urls
return count < 15 && success;
},
}; };
static indexExtensions(event: NostrEvent): Record<string, string> { static indexExtensions(event: NostrEvent): Record<string, string> {