ImportEtherpad: Warn about unsupported attrib at encounter

This commit is contained in:
Richard Hansen 2021-11-25 01:13:31 -05:00
parent 23f8a12922
commit ad78b24113

View file

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