feat: allow admin and user delete mail, sendbox, send access(only admin) (#329)

This commit is contained in:
Dream Hunter
2024-07-04 13:25:14 +08:00
committed by GitHub
parent 9448b3c754
commit 21fed3fb00
44 changed files with 344 additions and 278 deletions

View File

@@ -127,6 +127,16 @@ api.get('/admin/mails_unknow', async (c) => {
);
});
api.delete('/admin/mails/:id', async (c) => {
const { id } = c.req.param();
const { success } = await c.env.DB.prepare(
`DELETE FROM raw_mails WHERE id = ? `
).bind(id).run();
return c.json({
success: success
})
})
api.get('/admin/address_sender', async (c) => {
const { address, limit, offset } = c.req.query();
if (address) {
@@ -166,6 +176,16 @@ api.post('/admin/address_sender', async (c) => {
})
})
api.delete('/admin/address_sender/:id', async (c) => {
const { id } = c.req.param();
const { success } = await c.env.DB.prepare(
`DELETE FROM address_sender WHERE id = ? `
).bind(id).run();
return c.json({
success: success
})
})
api.get('/admin/sendbox', async (c) => {
const { address, limit, offset } = c.req.query();
if (address) {
@@ -182,6 +202,16 @@ api.get('/admin/sendbox', async (c) => {
);
})
api.delete('/admin/sendbox/:id', async (c) => {
const { id } = c.req.param();
const { success } = await c.env.DB.prepare(
`DELETE FROM sendbox WHERE id = ? `
).bind(id).run();
return c.json({
success: success
})
})
api.get('/admin/statistics', async (c) => {
const { count: mailCount } = await c.env.DB.prepare(
`SELECT count(*) as count FROM raw_mails`