From 043e2e2348b94caa98a3376c8a1e464f07362df4 Mon Sep 17 00:00:00 2001 From: Jules Date: Sun, 27 Sep 2026 20:20:22 +0200 Subject: [PATCH] =?UTF-8?q?fix(b5):=20la=20notification=20ntfy=20ne=20port?= =?UTF-8?q?e=20jamais=20d'extrait=20du=20texte=20libre=20;=20lien=20de=20m?= =?UTF-8?q?od=C3=A9ration=20public=20;=20trackingUrl=20mort=20retir=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Checkpoint Fable 27/09 : sans lien, nomSuggere() reprenait 60 caractères du texte du contributeur et les envoyait sur un topic ntfy (public par URL). Le nom n'est transmis que s'il vient d'un hostname. Click → sheets.trans-former.fr (localhost inutilisable depuis un téléphone). trackingUrl pointait nav.trans-former.fr/suivi/, page inexistante. Co-Authored-By: Claude Fable 5.1 --- server/api/submit/index.post.ts | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/server/api/submit/index.post.ts b/server/api/submit/index.post.ts index 76875e5..79087b5 100644 --- a/server/api/submit/index.post.ts +++ b/server/api/submit/index.post.ts @@ -207,7 +207,7 @@ export default defineEventHandler(async (event) => { nomSuggere: data.nom, typeSuggere: data.submission_type, nbLiens: data.url ? 1 : 0, - nocodbAdminUrl: 'http://localhost:8070', + nocodbAdminUrl: NOCODB_ADMIN_URL, }), ).catch((e) => console.warn('[submit] Notification ntfy échouée:', e?.message ?? e)) @@ -274,10 +274,10 @@ async function handleLibreSubmit(body: unknown) { process.env.NTFY_TOPIC, buildSubmissionNotif({ submissionId, - nomSuggere: payload.nom, + nomSuggere: nomPourNotif(payload.nom, data), typeSuggere: payload.submission_type, nbLiens: data.liens.length, - nocodbAdminUrl: 'http://localhost:8070', + nocodbAdminUrl: NOCODB_ADMIN_URL, }), ).catch((e) => console.warn('[submit] Notification ntfy échouée (libre):', e?.message ?? e)) @@ -285,10 +285,22 @@ async function handleLibreSubmit(body: unknown) { status: 201, submissionId, message: 'Ta fiche est en cours de traitement.', - trackingUrl: submissionId ? `https://nav.trans-former.fr/suivi/${submissionId}` : null, + trackingUrl: null, } } +/** URL de modération cliquable depuis la notification (téléphone) — jamais localhost. */ +const NOCODB_ADMIN_URL = 'https://sheets.trans-former.fr' + +/** + * Sans lien, `nomSuggere()` retombe sur les 60 premiers caractères du texte libre : + * ce texte ne doit jamais partir vers ntfy (topic public par URL). On ne transmet + * le nom que lorsqu'il est dérivé d'un hostname. + */ +function nomPourNotif(nom: string, data: LibreSubmitInput): string { + return data.liens.length > 0 ? nom : '[à qualifier] texte seul (voir NocoDB)' +} + async function insertReferenceLibre(config: ReturnType, data: LibreSubmitInput) { const payload = toReferencePayload(data) const insertUrl = `${config.nocodbUrl}/api/v1/db/data/noco/${config.nocodbBase}/${config.referencesTableId}` @@ -311,10 +323,10 @@ async function insertReferenceLibre(config: ReturnType, process.env.NTFY_TOPIC, buildSubmissionNotif({ submissionId: referenceId, - nomSuggere: payload.titre, + nomSuggere: nomPourNotif(payload.titre, data), typeSuggere: 'references', nbLiens: data.liens.length, - nocodbAdminUrl: 'http://localhost:8070', + nocodbAdminUrl: NOCODB_ADMIN_URL, }), ).catch((e) => console.warn('[submit] Notification ntfy échouée (référence libre):', e?.message ?? e))