import Route from "../route.js"; import initDb from "../db.js"; import auth from "../form/auth.js"; import { exec } from 'node:child_process'; import { promisify } from "node:util"; import captcha from "./captcha.js"; const execP = promisify(exec); let db = await initDb(); let main = new Route([auth, captcha], async function (req, res, input) { let { captchaMatch } = input; if (!captchaMatch) return { 'success': false, 'message': 'Captcha is incorrect' }; let { path } = req.file; let { username } = input; let { desc } = req.body; if (username == '!nobody' || !desc || !req.file) return { 'success': false, 'message': 'Some fields are missing' }; await execP(`magick ${path} pfp/${username}.png`); await db.run('DELETE FROM user WHERE username = ?', [ username, ]); await db.run('INSERT INTO user (username,bio) VALUES (?,?)', [ username, desc ]); res.send({ 'success': true, 'message': 'Metadata updated', redir: `/user?id=${username}` }); }); export default main;