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);
|
|
|
|
await storage.del(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,
|
|
|
|
owner: meta.owner,
|
|
|
|
download_count: meta.dl,
|
|
|
|
ttl
|
|
|
|
});
|
2017-08-24 23:54:02 +02:00
|
|
|
} catch (e) {
|
|
|
|
res.sendStatus(404);
|
|
|
|
}
|
|
|
|
};
|