2017-08-24 23:54:02 +02:00
|
|
|
const storage = require('../storage');
|
2019-02-12 20:50:06 +01:00
|
|
|
const { statDeleteEvent } = require('../amplitude');
|
2017-08-24 23:54:02 +02:00
|
|
|
|
|
|
|
module.exports = async function(req, res) {
|
|
|
|
try {
|
2019-02-12 20:50:06 +01:00
|
|
|
const id = req.params.id;
|
|
|
|
const meta = req.meta;
|
|
|
|
const ttl = await storage.ttl(id);
|
2020-07-13 19:21:28 +02:00
|
|
|
await storage.kill(id);
|
2018-02-06 23:31:18 +01:00
|
|
|
res.sendStatus(200);
|
2019-02-12 20:50:06 +01:00
|
|
|
statDeleteEvent({
|
|
|
|
id,
|
|
|
|
ip: req.ip,
|
2020-07-28 18:31:09 +02:00
|
|
|
country: req.geo.country,
|
|
|
|
state: req.geo.state,
|
2019-02-12 20:50:06 +01:00
|
|
|
owner: meta.owner,
|
|
|
|
download_count: meta.dl,
|
2019-05-03 18:25:12 +02:00
|
|
|
ttl,
|
|
|
|
agent: req.ua.browser.name || req.ua.ua.substring(0, 6)
|
2019-02-12 20:50:06 +01:00
|
|
|
});
|
2017-08-24 23:54:02 +02:00
|
|
|
} catch (e) {
|
|
|
|
res.sendStatus(404);
|
|
|
|
}
|
|
|
|
};
|