From 842e87543c07b979be3752dce1b859f8a443c519 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20FAMIBELLE-PRONZOLA?= Date: Sun, 5 Jul 2026 20:10:51 +0400 Subject: [PATCH] =?UTF-8?q?revert:=20garder=20les=20mentions=20dans=20les?= =?UTF-8?q?=20commentaires=20import=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__tests__/import-bokante-comments.test.js | 15 --------------- src/utils/import-bokante-comments.js | 8 +------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/src/utils/__tests__/import-bokante-comments.test.js b/src/utils/__tests__/import-bokante-comments.test.js index c9ba9ea..2110577 100644 --- a/src/utils/__tests__/import-bokante-comments.test.js +++ b/src/utils/__tests__/import-bokante-comments.test.js @@ -87,21 +87,6 @@ describe('importBokanteComments', () => { expect(result.imported).toBe(1); }); - it('retire la mention initiale du compte cité (déjà visible via l\'auteur)', async () => { - bokanteMastodon.getStatusContext = vi.fn(async () => ({ - descendants: [buildStatus({content: '

@pawol_nu Trè bèl !

'})] - })); - const paroles = [{id: 7, documentId: 'doc-7', slug: 'mon-titre', bokanteStatusId: '112233'}]; - const strapi = buildStrapi({paroles}); - - await importBokanteComments({strapi}); - - expect(strapi.documents('api::commentaire.commentaire').create).toHaveBeenCalledWith({ - status: 'published', - data: expect.objectContaining({contenu: 'Trè bèl !'}) - }); - }); - it('n\'importe pas un commentaire déjà présent (déduplication par remoteId)', async () => { bokanteMastodon.getStatusContext = vi.fn(async () => ({descendants: [buildStatus({id: 'deja-la'})]})); const paroles = [{id: 7, documentId: 'doc-7', slug: 'mon-titre', bokanteStatusId: '112233'}]; diff --git a/src/utils/import-bokante-comments.js b/src/utils/import-bokante-comments.js index 2302ea1..ab219e5 100644 --- a/src/utils/import-bokante-comments.js +++ b/src/utils/import-bokante-comments.js @@ -6,12 +6,6 @@ function stripHtml(html) { return (html || '').replace(/<[^>]*>/g, '').trim(); } -// Mastodon préfixe toujours une réponse par la mention du compte cité, -// déjà visible via l'avatar/le nom : redondant à l'affichage. -function stripMentionsInisyal(texte) { - return texte.replace(/^(@\S+\s*)+/, '').trim(); -} - async function importBokanteComments({strapi}) { const paroles = await strapi.db.query('api::parole.parole').findMany({ where: {bokanteStatusId: {$notNull: true}} @@ -45,7 +39,7 @@ async function importBokanteComments({strapi}) { const commentaire = await strapi.documents('api::commentaire.commentaire').create({ status: 'published', data: { - contenu: stripMentionsInisyal(stripHtml(status.content)), + contenu: stripHtml(status.content), datePublication: status.created_at, origine: 'activitypub', auteurNom: status.account?.display_name,