mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-05-27 19:19:56 +08:00
* feat: add empty address cleanup feature Add functionality to clean up email addresses that have never received any emails and were created more than N days ago. Changes: - Add emptyAddress cleanup type to backend cleanup logic - Add enableEmptyAddressAutoCleanup and cleanEmptyAddressDays to CleanupSettings model - Add scheduled task support for auto-cleanup of empty addresses - Add UI controls in Maintenance page for manual and auto cleanup - Add i18n support (English and Chinese translations) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * chore: update dependencies Update package.json and lock files across frontend, worker, pages, and vitepress-docs 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: update CHANGELOG for empty address cleanup feature Add entry for new maintenance page feature to clean up email addresses with no emails older than N days 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
68 lines
2.2 KiB
TypeScript
68 lines
2.2 KiB
TypeScript
import { Context } from 'hono';
|
|
import { cleanup } from './common'
|
|
import { CONSTANTS } from './constants'
|
|
import { getJsonSetting } from './utils';
|
|
import { CleanupSettings } from './models';
|
|
|
|
export async function scheduled(event: ScheduledEvent, env: Bindings, ctx: any) {
|
|
console.log("Scheduled event: ", event);
|
|
const autoCleanupSetting = await getJsonSetting<CleanupSettings>(
|
|
{ env: env, } as Context<HonoCustomType>,
|
|
CONSTANTS.AUTO_CLEANUP_KEY
|
|
);
|
|
if (!autoCleanupSetting) {
|
|
console.log("No auto cleanup settings found, skipping cleanup.");
|
|
return;
|
|
}
|
|
console.log("autoCleanupSetting:", JSON.stringify(autoCleanupSetting));
|
|
if (autoCleanupSetting.enableMailsAutoCleanup) {
|
|
await cleanup(
|
|
{ env: env, } as Context<HonoCustomType>,
|
|
"mails",
|
|
autoCleanupSetting.cleanMailsDays
|
|
);
|
|
}
|
|
if (autoCleanupSetting.enableUnknowMailsAutoCleanup) {
|
|
await cleanup(
|
|
{ env: env, } as Context<HonoCustomType>,
|
|
"mails_unknow",
|
|
autoCleanupSetting.cleanUnknowMailsDays
|
|
);
|
|
}
|
|
if (autoCleanupSetting.enableSendBoxAutoCleanup) {
|
|
await cleanup(
|
|
{ env: env, } as Context<HonoCustomType>,
|
|
"sendbox",
|
|
autoCleanupSetting.cleanSendBoxDays
|
|
);
|
|
}
|
|
if (autoCleanupSetting.enableInactiveAddressAutoCleanup) {
|
|
await cleanup(
|
|
{ env: env, } as Context<HonoCustomType>,
|
|
"inactiveAddress",
|
|
autoCleanupSetting.cleanInactiveAddressDays
|
|
);
|
|
}
|
|
if (autoCleanupSetting.enableAddressAutoCleanup) {
|
|
await cleanup(
|
|
{ env: env, } as Context<HonoCustomType>,
|
|
"addressCreated",
|
|
autoCleanupSetting.cleanAddressDays
|
|
);
|
|
}
|
|
if (autoCleanupSetting.enableUnboundAddressAutoCleanup) {
|
|
await cleanup(
|
|
{ env: env, } as Context<HonoCustomType>,
|
|
"unboundAddress",
|
|
autoCleanupSetting.cleanUnboundAddressDays
|
|
);
|
|
}
|
|
if (autoCleanupSetting.enableEmptyAddressAutoCleanup) {
|
|
await cleanup(
|
|
{ env: env, } as Context<HonoCustomType>,
|
|
"emptyAddress",
|
|
autoCleanupSetting.cleanEmptyAddressDays
|
|
);
|
|
}
|
|
}
|