mirror of
https://github.com/timvisee/send.git
synced 2025-10-05 10:29:26 +02:00
implemented download tokens
This commit is contained in:
parent
87d46f7ef5
commit
81e9d81dab
26 changed files with 271 additions and 126 deletions
25
server/routes/done.js
Normal file
25
server/routes/done.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
const storage = require('../storage');
|
||||
const { statDownloadEvent } = require('../amplitude');
|
||||
|
||||
module.exports = async function(req, res) {
|
||||
try {
|
||||
const id = req.params.id;
|
||||
const meta = req.meta;
|
||||
const ttl = await storage.ttl(id);
|
||||
statDownloadEvent({
|
||||
id,
|
||||
ip: req.ip,
|
||||
owner: meta.owner,
|
||||
download_count: meta.dl,
|
||||
ttl,
|
||||
agent: req.ua.browser.name || req.ua.ua.substring(0, 6)
|
||||
});
|
||||
await storage.incrementField(id, 'dl');
|
||||
if (meta.dlToken >= meta.dlimit) {
|
||||
await storage.kill(id);
|
||||
}
|
||||
res.sendStatus(200);
|
||||
} catch (e) {
|
||||
res.sendStatus(404);
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue