From ad78b2411345831f8043fe094fe7da6737940899 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Thu, 25 Nov 2021 01:13:31 -0500 Subject: [PATCH] ImportEtherpad: Warn about unsupported attrib at encounter --- src/node/utils/ImportEtherpad.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/node/utils/ImportEtherpad.js b/src/node/utils/ImportEtherpad.js index bc54e9ca1..de74fc41c 100644 --- a/src/node/utils/ImportEtherpad.js +++ b/src/node/utils/ImportEtherpad.js @@ -32,8 +32,6 @@ exports.setPadRaw = async (padId, r) => { supportedElems.add(element); }); - const unsupportedElements = new Set(); - // DB key prefixes for pad records. Each key is expected to have the form `${prefix}:${padId}` or // `${prefix}:${padId}:${otherstuff}`. const padKeyPrefixes = [ @@ -74,9 +72,14 @@ exports.setPadRaw = async (padId, r) => { } else if (padKeyPrefixes.includes(prefix)) { checkOriginalPadId(id); if (prefix === 'pad' && keyParts.length === 2 && value.pool) { + const unsupportedElements = new Set(); for (const [k] of Object.values(value.pool.numToAttrib)) { if (!supportedElems.has(k)) unsupportedElements.add(k); } + if (unsupportedElements.size) { + logger.warn(`(pad ${padId}) unsupported attributes (try installing a plugin): ` + + `${[...unsupportedElements].join(', ')}`); + } } keyParts[1] = padId; key = keyParts.join(':'); @@ -87,11 +90,6 @@ exports.setPadRaw = async (padId, r) => { dbRecords.set(key, value); })); - if (unsupportedElements.size) { - logger.warn('Ignoring unsupported elements (you might want to install a plugin): ' + - `${[...unsupportedElements].join(', ')}`); - } - await Promise.all([ ...[...dbRecords].map(async ([k, v]) => await db.set(k, v)), ...[...existingAuthors].map(async (authorId) => await authorManager.addPad(authorId, padId)),