ImportEtherpad: Use AttributePool to check attributes

pull/5304/head
Richard Hansen 2021-11-27 18:04:26 -05:00
parent 19909eae53
commit 5b3575acf0
1 changed files with 5 additions and 3 deletions

View File

@ -16,6 +16,7 @@
* limitations under the License. * limitations under the License.
*/ */
const AttributePool = require('../../static/js/AttributePool');
const {Pad} = require('../db/Pad'); const {Pad} = require('../db/Pad');
const authorManager = require('../db/AuthorManager'); const authorManager = require('../db/AuthorManager');
const db = require('../db/DB'); const db = require('../db/DB');
@ -72,11 +73,12 @@ exports.setPadRaw = async (padId, r) => {
value.padIDs = {[padId]: 1}; value.padIDs = {[padId]: 1};
} else if (padKeyPrefixes.includes(prefix)) { } else if (padKeyPrefixes.includes(prefix)) {
checkOriginalPadId(id); checkOriginalPadId(id);
if (prefix === 'pad' && keyParts.length === 2 && value.pool) { if (prefix === 'pad' && keyParts.length === 2) {
const pool = new AttributePool().fromJsonable(value.pool);
const unsupportedElements = new Set(); const unsupportedElements = new Set();
for (const [k] of Object.values(value.pool.numToAttrib)) { pool.eachAttrib((k, v) => {
if (!supportedElems.has(k)) unsupportedElements.add(k); if (!supportedElems.has(k)) unsupportedElements.add(k);
} });
if (unsupportedElements.size) { if (unsupportedElements.size) {
logger.warn(`(pad ${padId}) unsupported attributes (try installing a plugin): ` + logger.warn(`(pad ${padId}) unsupported attributes (try installing a plugin): ` +
`${[...unsupportedElements].join(', ')}`); `${[...unsupportedElements].join(', ')}`);