mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 16:36:15 -04:00
import/export: Simplify exportEtherpadAdditionalContent processing
Also: * Improve parallelization * Refine the documentation
This commit is contained in:
parent
8c55a38582
commit
6a8563eeab
3 changed files with 22 additions and 28 deletions
|
@ -59,17 +59,13 @@ exports.getPadRaw = async function(padId) {
|
|||
}
|
||||
}
|
||||
|
||||
await Promise.all([
|
||||
// get content that has a different prefix IE comments:padId:foo
|
||||
// a plugin would return something likle ["comments", "cakes"]
|
||||
hooks.aCallAll('exportEtherpadAdditionalContent').then((prefixes) => {
|
||||
prefixes.forEach(async function(prefix) {
|
||||
let pluginContent = await db.get(prefix + ":" + padId);
|
||||
data[prefix + ":" + padId] = pluginContent;
|
||||
});
|
||||
})
|
||||
]);
|
||||
|
||||
// get content that has a different prefix IE comments:padId:foo
|
||||
// a plugin would return something likle ['comments', 'cakes']
|
||||
const prefixes = await hooks.aCallAll('exportEtherpadAdditionalContent');
|
||||
await Promise.all(prefixes.map(async (prefix) => {
|
||||
const key = `${prefix}:${padId}`;
|
||||
data[key] = await db.get(key);
|
||||
}));
|
||||
|
||||
return data;
|
||||
}
|
||||
|
|
|
@ -65,17 +65,11 @@ exports.setPadRaw = function(padId, records)
|
|||
}
|
||||
|
||||
// is this a key that is supported through a plugin?
|
||||
await Promise.all([
|
||||
// get content that has a different prefix IE comments:padId:foo
|
||||
// a plugin would return something likle ["comments", "cakes"]
|
||||
hooks.aCallAll('exportEtherpadAdditionalContent').then((prefixes) => {
|
||||
prefixes.forEach(async function(prefix) {
|
||||
if(key.split(":")[0] === prefix){
|
||||
newKey = prefix + ":" + padId;
|
||||
}
|
||||
});
|
||||
})
|
||||
]);
|
||||
// get content that has a different prefix IE comments:padId:foo
|
||||
// a plugin would return something likle ['comments', 'cakes']
|
||||
for (const prefix of await hooks.aCallAll('exportEtherpadAdditionalContent')) {
|
||||
if (prefix === oldPadId[0]) newKey = `${prefix}:${padId}`;
|
||||
}
|
||||
}
|
||||
|
||||
// Write the value to the server
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue