From 3004bc1583b86076e48e79216e69d233a19065ee Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Mon, 11 Apr 2022 21:03:59 -0400 Subject: [PATCH] ExportEtherpad: Invert conditions to improve readability Also delete unnecessary comments. --- src/node/utils/ExportEtherpad.js | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/node/utils/ExportEtherpad.js b/src/node/utils/ExportEtherpad.js index 45683bc65..6b57625fe 100644 --- a/src/node/utils/ExportEtherpad.js +++ b/src/node/utils/ExportEtherpad.js @@ -31,25 +31,16 @@ exports.getPadRaw = async (padId, readOnlyId) => { const data = {}; for (const keySuffix of keySuffixes) { const entry = data[keyPrefixWrite + keySuffix] = await db.get(keyPrefixRead + keySuffix); - - // Get the Pad Authors - if (entry.pool && entry.pool.numToAttrib) { - const authors = entry.pool.numToAttrib; - - for (const k of Object.keys(authors)) { - if (authors[k][0] === 'author') { - const authorId = authors[k][1]; - - // Get the author info - const authorEntry = await db.get(`globalAuthor:${authorId}`); - if (authorEntry) { - data[`globalAuthor:${authorId}`] = authorEntry; - if (authorEntry.padIDs) { - authorEntry.padIDs = readOnlyId || padId; - } - } - } - } + 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}`); + if (!authorEntry) continue; + data[`globalAuthor:${authorId}`] = authorEntry; + if (!authorEntry.padIDs) continue; + authorEntry.padIDs = readOnlyId || padId; } }