From 637456631664edce7a2c8e605e2cfd850e924e72 Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Sun, 1 Mar 2026 17:46:02 +0100 Subject: [PATCH] feat: add language support --- lexicons/space/remanso/note.json | 2 +- src/data/db.ts | 9 ++++++--- src/data/note.ts | 1 + src/migrations/init.ts | 8 ++++++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lexicons/space/remanso/note.json b/lexicons/space/remanso/note.json index 4037e64..a02aeff 100644 --- a/lexicons/space/remanso/note.json +++ b/lexicons/space/remanso/note.json @@ -21,7 +21,7 @@ }, "language": { "type": "string", - "description": "Most used language in the note", + "description": "Most used language in the note. In ISO 639-3 code.", "maxLength": 10, "knownValues": [ "afr", diff --git a/src/data/db.ts b/src/data/db.ts index 66d80cf..4e9aaad 100644 --- a/src/data/db.ts +++ b/src/data/db.ts @@ -108,14 +108,16 @@ export const upsertNote = (note: Note) => { createdAt, did, rkey, - discoverable + discoverable, + language ) - VALUES (?, ?, ?, ?, ?, ?) + VALUES (?, ?, ?, ?, ?, ?, ?) ON CONFLICT(did, rkey) DO UPDATE SET title = excluded.title, publishedAt = excluded.publishedAt, - discoverable = excluded.discoverable + discoverable = excluded.discoverable, + language = excluded.language `, note.title, note.publishedAt ? new Date(note.publishedAt).toISOString() : now, @@ -123,5 +125,6 @@ export const upsertNote = (note: Note) => { note.did, note.rkey, note.discoverable !== false ? 1 : 0, + note.language, ); }; diff --git a/src/data/note.ts b/src/data/note.ts index a0fc354..49bb76e 100644 --- a/src/data/note.ts +++ b/src/data/note.ts @@ -5,4 +5,5 @@ export type Note = { publishedAt: string; createdAt: string; discoverable?: boolean; + language?: string }; diff --git a/src/migrations/init.ts b/src/migrations/init.ts index 494f2dd..0f271ce 100644 --- a/src/migrations/init.ts +++ b/src/migrations/init.ts @@ -20,6 +20,14 @@ try { // Column already exists — no-op } +try { + db.exec( + `ALTER TABLE note ADD COLUMN language STRING;`, + ); +} catch { + // Column already exists — no-op +} + try { db.exec(`ALTER TABLE note RENAME COLUMN listed TO discoverable;`); } catch {