diff options
author | tomsmeding <tom.smeding@gmail.com> | 2016-09-29 07:49:34 +0200 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2016-09-29 07:49:34 +0200 |
commit | e48b4ddffa8138045635ca2d3ee2e2efc1d15142 (patch) | |
tree | 46ecbfa799cf0cffd1f8aceaee049aea757634bf /modules | |
parent | 872b7a6341b8d1c92f39f54351acaa3821c12631 (diff) |
Backend support for history cleaning
Diffstat (limited to 'modules')
-rw-r--r-- | modules/changes/changes.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/modules/changes/changes.js b/modules/changes/changes.js index c3f24af..c923741 100644 --- a/modules/changes/changes.js +++ b/modules/changes/changes.js @@ -158,6 +158,35 @@ module.exports=function(app,io,_moddir){ persist.setItemSync("urls",urls); res.send(); }); + app.delete("/changes/url/delete",function(req,res){ + var param; + try {param=JSON.parse(req.body);} + catch(e){ + res.status(400); + res.send("Invalid JSON sent"); + } + var url=param.url; + var todate=new Date(param.todate); + if(!urls[url]){ + res.status(404); + res.send("URL not found in watch list"); + return; + } + if(todate.getTime()==NaN){ + res.status(400); + res.send("Invalid time sent"); + } + var tl=urls[url].timeline; + var i; + for(i=0;i<tl.length;i++){ + if(tl[i][0]<=todate){ + tl.splice(i,1); + i--; + } + } + res.status(200); + res.send(); + }); app.post("/changes/refresh",function(req,res){ refreshURLs(); res.send(); |