add pfps, some polish
This commit is contained in:
parent
351b9f2bc8
commit
85b3e55e3d
16 changed files with 142 additions and 230 deletions
34
form/settings.js
Normal file
34
form/settings.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
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";
|
||||
|
||||
const execP = promisify(exec);
|
||||
|
||||
let db = await initDb();
|
||||
|
||||
// TODO: rewrite
|
||||
let main = new Route([auth], async function (req, res, input) {
|
||||
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;
|
Loading…
Add table
Add a link
Reference in a new issue