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))