feat: Implement is_deleted flag for items, add new utility scripts, and refine UI styles.

This commit is contained in:
x
2026-01-24 17:24:22 +01:00
parent ee416a1d08
commit 63e86e9be1
9 changed files with 265 additions and 145 deletions

View File

@@ -11,11 +11,11 @@ export default async bot => {
f: async e => {
let deleted = [];
for(let id of e.args) {
for (let id of e.args) {
id = +id;
if(id <= 1)
if (id <= 1)
continue;
const f0ck = await db`
select dest, mime, username, userchannel, usernetwork
from "items"
@@ -26,36 +26,36 @@ export default async bot => {
`;
const level = getLevel(e.user).level;
if(f0ck.length === 0) {
if (f0ck.length === 0) {
await e.reply(`f0ck ${id}: f0ck not found`);
continue;
}
if(
if (
(f0ck[0].username !== (e.user.nick || e.user.username) ||
f0ck[0].userchannel !== e.channel ||
f0ck[0].usernetwork !== e.network) &&
f0ck[0].userchannel !== e.channel ||
f0ck[0].usernetwork !== e.network) &&
level < 100
) {
await e.reply(`f0ck ${id}: insufficient permissions`);
continue;
}
if(~~(new Date() / 1e3) >= (f0ck[0].stamp + 600) && level < 100) {
if (~~(new Date() / 1e3) >= (f0ck[0].stamp + 600) && level < 100) {
await e.reply(`f0ck ${id}: too late lol`);
continue;
}
await db`update "items" set active = 'false' where id = ${id}`;
await db`update "items" set active = 'false', is_deleted = true where id = ${id}`;
await fs.copyFile(`./public/b/${f0ck[0].dest}`, `./deleted/b/${f0ck[0].dest}`).catch(_=>{});
await fs.copyFile(`./public/t/${id}.webp`, `./deleted/t/${id}.webp`).catch(_=>{});
await fs.unlink(`./public/b/${f0ck[0].dest}`).catch(_=>{});
await fs.unlink(`./public/t/${id}.webp`).catch(_=>{});
await fs.copyFile(`./public/b/${f0ck[0].dest}`, `./deleted/b/${f0ck[0].dest}`).catch(_ => { });
await fs.copyFile(`./public/t/${id}.webp`, `./deleted/t/${id}.webp`).catch(_ => { });
await fs.unlink(`./public/b/${f0ck[0].dest}`).catch(_ => { });
await fs.unlink(`./public/t/${id}.webp`).catch(_ => { });
if(f0ck[0].mime.startsWith('audio')) {
await fs.copyFile(`./public/ca/${id}.webp`, `./deleted/ca/${id}.webp`).catch(_=>{});
await fs.unlink(`./public/ca/${id}.webp`).catch(_=>{});
if (f0ck[0].mime.startsWith('audio')) {
await fs.copyFile(`./public/ca/${id}.webp`, `./deleted/ca/${id}.webp`).catch(_ => { });
await fs.unlink(`./public/ca/${id}.webp`).catch(_ => { });
}
deleted.push(id);
@@ -71,11 +71,11 @@ export default async bot => {
f: async e => {
let recovered = [];
for(let id of e.args) {
for (let id of e.args) {
id = +id;
if(id <= 1)
if (id <= 1)
continue;
const f0ck = await db`
select dest, mime
from "items"
@@ -85,19 +85,19 @@ export default async bot => {
limit 1
`;
if(f0ck.length === 0) {
if (f0ck.length === 0) {
await e.reply(`f0ck ${id}: f0ck not found`);
continue;
}
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(_ => { });
}
await db`update "items" set active = 'true' where id = ${id}`;