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) {
const entry = data[keyPrefixWrite + keySuffix] = await db.get(keyPrefixRead + keySuffix);
if (!entry.pool || !entry.pool.numToAttrib) continue;
const authors = entry.pool.numToAttrib;
for (const k of Object.keys(authors)) {
if (authors[k][0] !== 'author') continue;
const authorId = authors[k][1];
const authorEntry = await db.get(`globalAuthor:${authorId}`);
for (const [k, v] of Object.values(entry.pool.numToAttrib)) {
if (k !== 'author') continue;
const authorEntry = await db.get(`globalAuthor:${v}`);
if (!authorEntry) continue;
data[`globalAuthor:${authorId}`] = authorEntry;
data[`globalAuthor:${v}`] = authorEntry;
if (!authorEntry.padIDs) continue;
authorEntry.padIDs = readOnlyId || padId;
}