2017-08-31 18:43:36 +02:00
|
|
|
const storage = require('../storage');
|
|
|
|
|
|
|
|
module.exports = async function(req, res) {
|
|
|
|
const id = req.params.id;
|
2018-02-06 23:31:18 +01:00
|
|
|
const meta = req.meta;
|
2017-08-31 18:43:36 +02:00
|
|
|
try {
|
2020-07-13 19:21:28 +02:00
|
|
|
if (meta.dead && !meta.flagged) {
|
|
|
|
return res.sendStatus(404);
|
|
|
|
}
|
2017-08-31 18:43:36 +02:00
|
|
|
const ttl = await storage.ttl(id);
|
|
|
|
res.send({
|
|
|
|
metadata: meta.metadata,
|
2020-07-13 19:21:28 +02:00
|
|
|
flagged: !!meta.flagged,
|
2020-07-27 20:18:52 +02:00
|
|
|
finalDownload: meta.dlToken + 1 === meta.dlimit,
|
2017-08-31 18:43:36 +02:00
|
|
|
ttl
|
|
|
|
});
|
|
|
|
} catch (e) {
|
|
|
|
res.sendStatus(404);
|
|
|
|
}
|
|
|
|
};
|