mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
DittoPgStore: call expandFilters in .req
This commit is contained in:
parent
d05dd16507
commit
9401c0e013
1 changed files with 14 additions and 20 deletions
|
|
@ -267,6 +267,8 @@ export class DittoPgStore extends NPostgres {
|
|||
const { db, chunkSize = 20 } = this.opts;
|
||||
const { timeout = this.opts.timeout, signal } = opts;
|
||||
|
||||
filters = await this.expandFilters(filters);
|
||||
|
||||
const subId = crypto.randomUUID();
|
||||
const normalFilters = this.normalizeFilters(filters);
|
||||
const machina = new Machina<NostrRelayEVENT | NostrRelayEOSE | NostrRelayCLOSED>(signal);
|
||||
|
|
@ -337,20 +339,6 @@ export class DittoPgStore extends NPostgres {
|
|||
): Promise<DittoEvent[]> {
|
||||
filters = await this.expandFilters(filters);
|
||||
|
||||
for (const filter of filters) {
|
||||
if (filter.since && filter.since >= 2_147_483_647) {
|
||||
throw new RelayError('invalid', 'since filter too far into the future');
|
||||
}
|
||||
if (filter.until && filter.until >= 2_147_483_647) {
|
||||
throw new RelayError('invalid', 'until filter too far into the future');
|
||||
}
|
||||
for (const kind of filter.kinds ?? []) {
|
||||
if (kind >= 2_147_483_647) {
|
||||
throw new RelayError('invalid', 'kind filter too far into the future');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (opts.signal?.aborted) return Promise.resolve([]);
|
||||
|
||||
logi({ level: 'debug', ns: 'ditto.req', source: 'db', filters: filters as JsonValue });
|
||||
|
|
@ -531,6 +519,18 @@ export class DittoPgStore extends NPostgres {
|
|||
filters = structuredClone(filters);
|
||||
|
||||
for (const filter of filters) {
|
||||
if (filter.since && filter.since >= 2_147_483_647) {
|
||||
throw new RelayError('invalid', 'since filter too far into the future');
|
||||
}
|
||||
if (filter.until && filter.until >= 2_147_483_647) {
|
||||
throw new RelayError('invalid', 'until filter too far into the future');
|
||||
}
|
||||
for (const kind of filter.kinds ?? []) {
|
||||
if (kind >= 2_147_483_647) {
|
||||
throw new RelayError('invalid', 'kind filter too far into the future');
|
||||
}
|
||||
}
|
||||
|
||||
if (filter.search) {
|
||||
const tokens = NIP50.parseInput(filter.search);
|
||||
|
||||
|
|
@ -581,12 +581,6 @@ export class DittoPgStore extends NPostgres {
|
|||
.map((t) => typeof t === 'object' ? `${t.key}:${t.value}` : t)
|
||||
.join(' ');
|
||||
}
|
||||
|
||||
if (filter.kinds) {
|
||||
// Ephemeral events are not stored, so don't bother querying for them.
|
||||
// If this results in an empty kinds array, NDatabase will remove the filter before querying and return no results.
|
||||
filter.kinds = filter.kinds.filter((kind) => !NKinds.ephemeral(kind));
|
||||
}
|
||||
}
|
||||
|
||||
return filters;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue