ExportEtherpad: Simplify attribute pool iteration

This commit is contained in:
Richard Hansen 2022-04-13 04:13:17 -04:00
parent 3004bc1583
commit 56a60a34fb

View file

@ -32,13 +32,11 @@ exports.getPadRaw = async (padId, readOnlyId) => {
for (const keySuffix of keySuffixes) { for (const keySuffix of keySuffixes) {
const entry = data[keyPrefixWrite + keySuffix] = await db.get(keyPrefixRead + keySuffix); const entry = data[keyPrefixWrite + keySuffix] = await db.get(keyPrefixRead + keySuffix);
if (!entry.pool || !entry.pool.numToAttrib) continue; if (!entry.pool || !entry.pool.numToAttrib) continue;
const authors = entry.pool.numToAttrib; for (const [k, v] of Object.values(entry.pool.numToAttrib)) {
for (const k of Object.keys(authors)) { if (k !== 'author') continue;
if (authors[k][0] !== 'author') continue; const authorEntry = await db.get(`globalAuthor:${v}`);
const authorId = authors[k][1];
const authorEntry = await db.get(`globalAuthor:${authorId}`);
if (!authorEntry) continue; if (!authorEntry) continue;
data[`globalAuthor:${authorId}`] = authorEntry; data[`globalAuthor:${v}`] = authorEntry;
if (!authorEntry.padIDs) continue; if (!authorEntry.padIDs) continue;
authorEntry.padIDs = readOnlyId || padId; authorEntry.padIDs = readOnlyId || padId;
} }