chat: Move message deletion to `padRemove` hook
parent
bd621043ff
commit
b6bcc092ed
|
@ -28,6 +28,7 @@
|
|||
"padCheck": "ep_etherpad-lite/node/chat",
|
||||
"padCopy": "ep_etherpad-lite/node/chat",
|
||||
"padLoad": "ep_etherpad-lite/node/chat",
|
||||
"padRemove": "ep_etherpad-lite/node/chat",
|
||||
"socketio": "ep_etherpad-lite/node/chat"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -173,6 +173,14 @@ exports.padLoad = async (hookName, {pad}) => {
|
|||
if (!('chatHead' in pad)) pad.chatHead = -1;
|
||||
};
|
||||
|
||||
exports.padRemove = async (hookName, {pad}) => {
|
||||
const ops = (function* () {
|
||||
const {chatHead = -1} = pad;
|
||||
for (let i = 0; i <= chatHead; ++i) yield pad.db.remove(`pad:${pad.id}:chat:${i}`);
|
||||
})();
|
||||
for (const op of new Stream(ops).batch(100).buffer(99)) await op;
|
||||
};
|
||||
|
||||
exports.socketio = (hookName, {io}) => {
|
||||
socketio = io;
|
||||
};
|
||||
|
|
|
@ -530,11 +530,6 @@ class Pad {
|
|||
}));
|
||||
p.push(db.remove(`pad2readonly:${padID}`));
|
||||
|
||||
// delete all chat messages
|
||||
p.push(promises.timesLimit(this.chatHead + 1, 500, async (i) => {
|
||||
await this.db.remove(`pad:${this.id}:chat:${i}`, null);
|
||||
}));
|
||||
|
||||
// delete all revisions
|
||||
p.push(promises.timesLimit(this.head + 1, 500, async (i) => {
|
||||
await this.db.remove(`pad:${this.id}:revs:${i}`, null);
|
||||
|
|
Loading…
Reference in New Issue