add processing server check
This commit is contained in:
@ -194,22 +194,29 @@ async function editProfile(body, token, admin) {
|
||||
let fileType = (await fileTypeFromBuffer(pfp))["ext"];
|
||||
if (["png", "jpg", "gif", "avif", "webp", "tiff"].includes(fileType)) {
|
||||
let url;
|
||||
let dir = `${process.env.DATA_PATH}/data/${existingAccount.id}/`;
|
||||
let dir = `${process.env.DATA_PATH}/data/${userData.id}/`;
|
||||
let uuid = crypto.randomUUID();
|
||||
let path = `${process.env.DATA_PATH}/data/${existingAccount.id}/${uuid}.webp`;
|
||||
url = `/data/${existingAccount.id}/${uuid}.webp`;
|
||||
let path = `${process.env.DATA_PATH}/data/${userData.id}/${uuid}.webp`;
|
||||
url = `/data/${userData.id}/${uuid}.webp`;
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
fs.writeFileSync(path, "");
|
||||
await sharp(pfp, { animated: fileType == "gif" })
|
||||
.resize({ width: 300, withoutEnlargement: true })
|
||||
.webp({ quality: 70, effort: 4 })
|
||||
.toFile(path);
|
||||
await fs.unlink(`${__dirname}/${existingAccount.pfp_url}`, () => {});
|
||||
await fs.unlink(`${__dirname}/${userData.pfp_url}`, () => {});
|
||||
const updateAccount = accs.query(`UPDATE accounts SET pfp_url = $url WHERE username = $user`)
|
||||
updateAccount.get({ $url: url, $user: user });
|
||||
}
|
||||
}
|
||||
if (body.artist) {
|
||||
let checkStatus = new Request({
|
||||
url: process.env.PROCESSING_SERVER + "/status"
|
||||
});
|
||||
let checkStatusRequest = await fetch(checkStatus);
|
||||
if(checkStatusRequest.status != 200) {
|
||||
return { success: false, err: "processing server is down, try again later"};
|
||||
}
|
||||
let path = await download(body.url);
|
||||
console.log("exit download");
|
||||
let file = Bun.file(path);
|
||||
@ -224,7 +231,7 @@ async function editProfile(body, token, admin) {
|
||||
console.log("created request");
|
||||
let oggFile = await fetch(request);
|
||||
console.log("finished request");
|
||||
let filePath = `/data/${existingAccount.id}/${crypto.randomUUID()}.ogg`;
|
||||
let filePath = `/data/${userData.id}/${crypto.randomUUID()}.ogg`;
|
||||
await Bun.write(process.env.DATA_PATH + filePath, oggFile);
|
||||
const updateAccount = accs.query(`UPDATE accounts SET music = $music WHERE username = $user`)
|
||||
updateAccount.get({ $music: JSON.stringify({
|
||||
|
Reference in New Issue
Block a user