mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 00:16:15 -04:00
chat: Move message deletion to padRemove
hook
This commit is contained in:
parent
bd621043ff
commit
b6bcc092ed
3 changed files with 9 additions and 5 deletions
|
@ -28,6 +28,7 @@
|
||||||
"padCheck": "ep_etherpad-lite/node/chat",
|
"padCheck": "ep_etherpad-lite/node/chat",
|
||||||
"padCopy": "ep_etherpad-lite/node/chat",
|
"padCopy": "ep_etherpad-lite/node/chat",
|
||||||
"padLoad": "ep_etherpad-lite/node/chat",
|
"padLoad": "ep_etherpad-lite/node/chat",
|
||||||
|
"padRemove": "ep_etherpad-lite/node/chat",
|
||||||
"socketio": "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;
|
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}) => {
|
exports.socketio = (hookName, {io}) => {
|
||||||
socketio = io;
|
socketio = io;
|
||||||
};
|
};
|
||||||
|
|
|
@ -530,11 +530,6 @@ class Pad {
|
||||||
}));
|
}));
|
||||||
p.push(db.remove(`pad2readonly:${padID}`));
|
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
|
// delete all revisions
|
||||||
p.push(promises.timesLimit(this.head + 1, 500, async (i) => {
|
p.push(promises.timesLimit(this.head + 1, 500, async (i) => {
|
||||||
await this.db.remove(`pad:${this.id}:revs:${i}`, null);
|
await this.db.remove(`pad:${this.id}:revs:${i}`, null);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue