mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
fix: type assertions in EventsDB
This commit is contained in:
parent
6c93153117
commit
3f00f255a5
2 changed files with 3 additions and 7 deletions
|
|
@ -1,5 +1,3 @@
|
||||||
import { Nullable } from 'kysely';
|
|
||||||
|
|
||||||
import { NPostgresSchema } from '@nostrify/db';
|
import { NPostgresSchema } from '@nostrify/db';
|
||||||
|
|
||||||
export interface DittoTables extends NPostgresSchema {
|
export interface DittoTables extends NPostgresSchema {
|
||||||
|
|
@ -12,7 +10,7 @@ export interface DittoTables extends NPostgresSchema {
|
||||||
}
|
}
|
||||||
|
|
||||||
type NostrEventsRow = NPostgresSchema['nostr_events'] & {
|
type NostrEventsRow = NPostgresSchema['nostr_events'] & {
|
||||||
language: Nullable<string>;
|
language: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface AuthorStatsRow {
|
interface AuthorStatsRow {
|
||||||
|
|
|
||||||
|
|
@ -146,16 +146,14 @@ class EventsDB extends NPostgres {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-ignore The type is correct, but NPostgres doesn't realize it. I don't think it's solvable without modifying NPostgres again, which I don't think is worth it for this.
|
|
||||||
protected override getFilterQuery(trx: Kysely<NPostgresSchema>, filter: NostrFilter) {
|
protected override getFilterQuery(trx: Kysely<NPostgresSchema>, filter: NostrFilter) {
|
||||||
if (filter.search) {
|
if (filter.search) {
|
||||||
const tokens = NIP50.parseInput(filter.search);
|
const tokens = NIP50.parseInput(filter.search);
|
||||||
|
|
||||||
// @ts-ignore The type is correct, but NPostgres doesn't realize it. I don't think it's solvable without modifying NPostgres again, which I don't think is worth it for this.
|
|
||||||
let query = super.getFilterQuery(trx, {
|
let query = super.getFilterQuery(trx, {
|
||||||
...filter,
|
...filter,
|
||||||
search: tokens.filter((t) => typeof t === 'string').join(' '),
|
search: tokens.filter((t) => typeof t === 'string').join(' '),
|
||||||
}) as SelectQueryBuilder<DittoTables, 'nostr_events', Pick<DittoTables['nostr_events'], keyof NostrEvent>>;
|
}) as SelectQueryBuilder<DittoTables, 'nostr_events', DittoTables['nostr_events']>;
|
||||||
|
|
||||||
const languages = new Set<string>();
|
const languages = new Set<string>();
|
||||||
|
|
||||||
|
|
@ -204,7 +202,7 @@ class EventsDB extends NPostgres {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Parse an event row from the database. */
|
/** Parse an event row from the database. */
|
||||||
protected override parseEventRow(row: Pick<DittoTables['nostr_events'], keyof NostrEvent | 'language'>): DittoEvent {
|
protected override parseEventRow(row: DittoTables['nostr_events']): DittoEvent {
|
||||||
return {
|
return {
|
||||||
id: row.id,
|
id: row.id,
|
||||||
kind: row.kind,
|
kind: row.kind,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue