Add loop option

It allows to disable the deletion loops, useful if you use
https://framagit.org/framasoft/pad_delete_after_delay for example.
This commit is contained in:
Luc Didry 2016-11-15 13:34:10 +01:00
parent 4551fa3742
commit 6d871e73ac
3 changed files with 8 additions and 2 deletions

View file

@ -8,6 +8,7 @@ Install the plugin and put this in your `settings.json`:
"ep_delete_after_delay": {
"delay": 86400, // one day, in seconds
"loop": true,
"loopDelay": 3600, // one hour, in seconds
"deleteAtStart": true,
"text": "The content of this pad has been deleted since it was older than the configured delay."
@ -15,6 +16,8 @@ Install the plugin and put this in your `settings.json`:
`delay` (mandatory) delay in seconds with no edition of the pad before deletion. You can't put `7*86400` for a week, you have to put `604800`.
`loop` binary, tells if you want to use deletion loops (`true`) or not (`false`) (if you use [an external script](https://framagit.org/framasoft/pad_delete_after_delay) for example). Default is true.
`loopDelay` delay in seconds between deletion loops. Deletion loop will check all pads to see if they have to be deleted. You can't put `60*60` for a hour, you have to put `3600`. Default is one hour.
`deleteAtStart` binary, tells if you want to start a deletion loop at Etherpad startup. Default is true.

View file

@ -18,6 +18,7 @@ var areParamsOk = (settings.ep_delete_after_delay) ? true : false,
delay, replaceText, loopDelay, deleteAtStart;
if (areParamsOk) {
delay = settings.ep_delete_after_delay.delay;
loop = (settings.ep_delete_after_delay.loop !== undefined) ? settings.ep_delete_after_delay.loop : true;
loopDelay = settings.ep_delete_after_delay.loopDelay || 3600;
deleteAtStart = (settings.ep_delete_after_delay.deleteAtStart !== undefined) ? settings.ep_delete_after_delay.deleteAtStart : true;
replaceText = settings.ep_delete_after_delay.text || "The content of this pad has been deleted since it was older than the configured delay.";
@ -48,7 +49,9 @@ if (deleteAtStart) {
}
// start the recurring deletion loop
if (loop) {
waitForIt();
}
// deletion loop
function delete_old_pads() {

View file

@ -1,7 +1,7 @@
{
"name": "ep_delete_after_delay",
"version": "0.0.5",
"version": "0.0.6",
"description": "Automatically deletes pads after a configured delay",
"author": {
"name": "Luc Didry",