removing some of the admin functionality for now

This commit is contained in:
x 2025-05-02 19:14:14 +02:00
parent dcc6eac07a
commit cd1f99af48
2 changed files with 66 additions and 64 deletions

View File

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

View File

@ -12,8 +12,8 @@
<div class="admintools"> <div class="admintools">
<p>Adminwerkzeuge</p> <p>Adminwerkzeuge</p>
<ul> <ul>
<li><a href="/admin/log">Logs</a></li> <!-- <li><a href="/admin/log">Logs</a></li>
<li><a href="/admin/recover">Recover f0cks</a></li> <li><a href="/admin/recover">Recover f0cks</a></li> -->
<li><a href="/admin/sessions">Sessions</a></li> <li><a href="/admin/sessions">Sessions</a></li>
</ul> </ul>
</div> </div>