feat: add language support

This commit is contained in:
Julien Calixte
2026-03-01 17:46:02 +01:00
parent 2b54c8dd00
commit 6374566316
4 changed files with 16 additions and 4 deletions

View File

@@ -21,7 +21,7 @@
}, },
"language": { "language": {
"type": "string", "type": "string",
"description": "Most used language in the note", "description": "Most used language in the note. In ISO 639-3 code.",
"maxLength": 10, "maxLength": 10,
"knownValues": [ "knownValues": [
"afr", "afr",

View File

@@ -108,14 +108,16 @@ export const upsertNote = (note: Note) => {
createdAt, createdAt,
did, did,
rkey, rkey,
discoverable discoverable,
language
) )
VALUES (?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?)
ON CONFLICT(did, rkey) ON CONFLICT(did, rkey)
DO UPDATE SET DO UPDATE SET
title = excluded.title, title = excluded.title,
publishedAt = excluded.publishedAt, publishedAt = excluded.publishedAt,
discoverable = excluded.discoverable discoverable = excluded.discoverable,
language = excluded.language
`, `,
note.title, note.title,
note.publishedAt ? new Date(note.publishedAt).toISOString() : now, note.publishedAt ? new Date(note.publishedAt).toISOString() : now,
@@ -123,5 +125,6 @@ export const upsertNote = (note: Note) => {
note.did, note.did,
note.rkey, note.rkey,
note.discoverable !== false ? 1 : 0, note.discoverable !== false ? 1 : 0,
note.language,
); );
}; };

View File

@@ -5,4 +5,5 @@ export type Note = {
publishedAt: string; publishedAt: string;
createdAt: string; createdAt: string;
discoverable?: boolean; discoverable?: boolean;
language?: string
}; };

View File

@@ -20,6 +20,14 @@ try {
// Column already exists — no-op // Column already exists — no-op
} }
try {
db.exec(
`ALTER TABLE note ADD COLUMN language STRING;`,
);
} catch {
// Column already exists — no-op
}
try { try {
db.exec(`ALTER TABLE note RENAME COLUMN listed TO discoverable;`); db.exec(`ALTER TABLE note RENAME COLUMN listed TO discoverable;`);
} catch { } catch {