mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-06-29 19:32:04 +08:00
feat: add empty address cleanup feature (#765)
* 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>
This commit is contained in:
@@ -273,6 +273,13 @@ export const cleanup = async (
|
||||
DELETE FROM sendbox WHERE created_at < datetime('now', '-${cleanDays} day')`
|
||||
).run();
|
||||
break;
|
||||
case "emptyAddress":
|
||||
// Delete addresses that have no emails and were created more than N days ago
|
||||
await batchDeleteAddressWithData(
|
||||
c,
|
||||
`name NOT IN (SELECT DISTINCT address FROM raw_mails WHERE address IS NOT NULL) AND created_at < datetime('now', '-${cleanDays} day')`
|
||||
)
|
||||
break;
|
||||
default:
|
||||
throw new Error("Invalid cleanType")
|
||||
}
|
||||
|
||||
@@ -48,6 +48,8 @@ export type CleanupSettings = {
|
||||
cleanInactiveAddressDays: number;
|
||||
enableUnboundAddressAutoCleanup: boolean | undefined;
|
||||
cleanUnboundAddressDays: number;
|
||||
enableEmptyAddressAutoCleanup: boolean | undefined;
|
||||
cleanEmptyAddressDays: number;
|
||||
}
|
||||
|
||||
export class GeoData {
|
||||
|
||||
@@ -57,4 +57,11 @@ export async function scheduled(event: ScheduledEvent, env: Bindings, ctx: any)
|
||||
autoCleanupSetting.cleanUnboundAddressDays
|
||||
);
|
||||
}
|
||||
if (autoCleanupSetting.enableEmptyAddressAutoCleanup) {
|
||||
await cleanup(
|
||||
{ env: env, } as Context<HonoCustomType>,
|
||||
"emptyAddress",
|
||||
autoCleanupSetting.cleanEmptyAddressDays
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user