diff --git a/src/inc/routes/admin.mjs b/src/inc/routes/admin.mjs index 60ad38a..af1f67a 100644 --- a/src/inc/routes/admin.mjs +++ b/src/inc/routes/admin.mjs @@ -121,77 +121,79 @@ export default (router, tpl) => { }); }); - router.get(/^\/admin\/log(\/)?$/, lib.auth, async (req, res) => { - exec("journalctl -qeu f0ck --no-pager", (err, stdout) => { - res.reply({ - body: tpl.render("admin/log", { - log: stdout.split("\n").slice(0, -1), - tmp: null - }, req) - }); - }); - }); + // router.get(/^\/admin\/log(\/)?$/, lib.auth, async (req, res) => { + // // Funktioniert ohne systemd service natürlich nicht. + // exec("journalctl -qeu f0ck --no-pager", (err, stdout) => { + // res.reply({ + // body: tpl.render("admin/log", { + // log: stdout.split("\n").slice(0, -1), + // tmp: null + // }, req) + // }); + // }); + // }); - router.get(/^\/admin\/recover\/?/, lib.auth, async (req, res) => { - if(req.url.qs?.id) { - const id = +req.url.qs.id; - const f0ck = await db` - select dest, mime - from "items" - where - id = ${id} and - active = 'false' - limit 1 - `; - if(f0ck.length === 0) { - return res.reply({ - body: `f0ck ${id}: f0ck not found` - }); - } + // router.get(/^\/admin\/recover\/?/, lib.auth, async (req, res) => { + // Gelöschte Objekte werden nicht aufgehoben. + // if(req.url.qs?.id) { + // const id = +req.url.qs.id; + // const f0ck = await db` + // select dest, mime + // from "items" + // where + // id = ${id} and + // active = 'false' + // limit 1 + // `; + // if(f0ck.length === 0) { + // return res.reply({ + // body: `f0ck ${id}: f0ck not found` + // }); + // } - await db`update "items" set active = 'true' where id = ${id}`; + // await db`update "items" set active = 'true' where id = ${id}`; - await fs.copyFile(`./deleted/b/${f0ck[0].dest}`, `./public/b/${f0ck[0].dest}`).catch(_=>{}); - await fs.copyFile(`./deleted/t/${id}.webp`, `./public/t/${id}.webp`).catch(_=>{}); - await fs.unlink(`./deleted/b/${f0ck[0].dest}`).catch(_=>{}); - await fs.unlink(`./deleted/t/${id}.webp`).catch(_=>{}); + // await fs.copyFile(`./deleted/b/${f0ck[0].dest}`, `./public/b/${f0ck[0].dest}`).catch(_=>{}); + // await fs.copyFile(`./deleted/t/${id}.webp`, `./public/t/${id}.webp`).catch(_=>{}); + // await fs.unlink(`./deleted/b/${f0ck[0].dest}`).catch(_=>{}); + // await fs.unlink(`./deleted/t/${id}.webp`).catch(_=>{}); - if(f0ck[0].mime.startsWith('audio')) { - await fs.copyFile(`./deleted/ca/${id}.webp`, `./public/ca/${id}.webp`).catch(_=>{}); - await fs.unlink(`./deleted/ca/${id}.webp`).catch(_=>{}); - } + // if(f0ck[0].mime.startsWith('audio')) { + // await fs.copyFile(`./deleted/ca/${id}.webp`, `./public/ca/${id}.webp`).catch(_=>{}); + // await fs.unlink(`./deleted/ca/${id}.webp`).catch(_=>{}); + // } - return res.reply({ - body: `f0ck ${id} recovered. back` - }); - } + // return res.reply({ + // body: `f0ck ${id} recovered. back` + // }); + // } - const _posts = await db` - select id, mime, username - from "items" - where - active = 'false' - order by id desc - `; + // const _posts = await db` + // select id, mime, username + // from "items" + // where + // active = 'false' + // order by id desc + // `; - if(_posts.length === 0) { - return res.reply({ - body: 'blah' - }); - } + // if(_posts.length === 0) { + // return res.reply({ + // body: 'blah' + // }); + // } - const posts = await Promise.all(_posts.map(async p => ({ - ...p, - thumbnail: (await fs.readFile(`./deleted/t/${p.id}.webp`)).toString('base64') - }))); + // const posts = await Promise.all(_posts.map(async p => ({ + // ...p, + // thumbnail: (await fs.readFile(`./deleted/t/${p.id}.webp`)).toString('base64') + // }))); - res.reply({ - body: tpl.render('admin/recover', { - posts, - tmp: null - }, req) - }); - }); + // res.reply({ + // body: tpl.render('admin/recover', { + // posts, + // tmp: null + // }, req) + // }); + // }); return router; }; diff --git a/views/admin.html b/views/admin.html index a144f8e..568a498 100644 --- a/views/admin.html +++ b/views/admin.html @@ -12,8 +12,8 @@

Adminwerkzeuge