|
|
@ -3,6 +3,7 @@ import { BusBoyFile, AssFile } from 'ass';
|
|
|
|
import fs from 'fs-extra';
|
|
|
|
import fs from 'fs-extra';
|
|
|
|
import bb from 'express-busboy';
|
|
|
|
import bb from 'express-busboy';
|
|
|
|
import crypto from 'crypto';
|
|
|
|
import crypto from 'crypto';
|
|
|
|
|
|
|
|
import fetch from 'node-fetch';
|
|
|
|
import { Router } from 'express';
|
|
|
|
import { Router } from 'express';
|
|
|
|
import { Readable } from 'stream';
|
|
|
|
import { Readable } from 'stream';
|
|
|
|
|
|
|
|
|
|
|
@ -88,7 +89,21 @@ router.post('/', rateLimiterMiddleware("upload", UserConfig.config?.rateLimit?.u
|
|
|
|
data.put('files', assFile.fakeid, assFile);
|
|
|
|
data.put('files', assFile.fakeid, assFile);
|
|
|
|
|
|
|
|
|
|
|
|
log.debug('File saved to', !s3 ? assFile.save.local! : 'S3');
|
|
|
|
log.debug('File saved to', !s3 ? assFile.save.local! : 'S3');
|
|
|
|
return res.type('json').send({ resource: `${req.ass.host}/${assFile.fakeid}` });
|
|
|
|
await res.type('json').send({ resource: `${req.ass.host}/${assFile.fakeid}` });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Send to Discord webhook
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
await fetch(UserConfig.config.discordWebhook, {
|
|
|
|
|
|
|
|
method: "POST",
|
|
|
|
|
|
|
|
headers: {
|
|
|
|
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
body: JSON.stringify({ content: `New upload: ${req.ass.host}/${assFile.fakeid}` })
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
|
|
log.warn("Failed to send request to Discord webhook");
|
|
|
|
|
|
|
|
console.error(err);
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
log.error('Failed to upload file', bbFile.filename);
|
|
|
|
log.error('Failed to upload file', bbFile.filename);
|
|
|
|
console.error(err);
|
|
|
|
console.error(err);
|
|
|
|