mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-24 01:16:15 -04:00
ExportEtherpad: New importEtherpad
, exportEtherpad
hooks
This commit is contained in:
parent
44fd70491d
commit
2facf3a0c5
4 changed files with 57 additions and 1 deletions
|
@ -55,5 +55,10 @@ exports.getPadRaw = async (padId, readOnlyId) => {
|
|||
})();
|
||||
const data = {[dstPfx]: pad};
|
||||
for (const [dstKey, p] of new Stream(records).batch(100).buffer(99)) data[dstKey] = await p;
|
||||
await hooks.aCallAll('exportEtherpad', {
|
||||
pad,
|
||||
data,
|
||||
dstPadId: readOnlyId || padId,
|
||||
});
|
||||
return data;
|
||||
};
|
||||
|
|
|
@ -90,7 +90,8 @@ exports.setPadRaw = async (padId, r, authorId = '') => {
|
|||
keyParts[1] = padId;
|
||||
key = keyParts.join(':');
|
||||
} else {
|
||||
logger.warn(`(pad ${padId}) Ignoring record with unsupported key: ${key}`);
|
||||
logger.debug(`(pad ${padId}) The record with the following key will be ignored unless an ` +
|
||||
`importEtherpad hook function processes it: ${key}`);
|
||||
return;
|
||||
}
|
||||
await padDb.set(key, value);
|
||||
|
@ -100,6 +101,13 @@ exports.setPadRaw = async (padId, r, authorId = '') => {
|
|||
|
||||
const pad = new Pad(padId, padDb);
|
||||
await pad.init(null, authorId);
|
||||
await hooks.aCallAll('importEtherpad', {
|
||||
pad,
|
||||
// Shallow freeze meant to prevent accidental bugs. It would be better to deep freeze, but
|
||||
// it's not worth the added complexity.
|
||||
data: Object.freeze(records),
|
||||
srcPadId: originalPadId,
|
||||
});
|
||||
await pad.check();
|
||||
} finally {
|
||||
await padDb.close();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue