mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-07-21 04:21:50 +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:
@@ -11,26 +11,26 @@
|
||||
"build": "wrangler deploy --dry-run --outdir dist --minify"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cloudflare/workers-types": "^4.20251107.0",
|
||||
"@cloudflare/workers-types": "^4.20251111.0",
|
||||
"@eslint/js": "9.18.0",
|
||||
"@simplewebauthn/types": "10.0.0",
|
||||
"@types/node": "^22.19.0",
|
||||
"@types/node": "^22.19.1",
|
||||
"eslint": "9.18.0",
|
||||
"globals": "^15.15.0",
|
||||
"typescript-eslint": "^8.46.3",
|
||||
"wrangler": "^4.46.0"
|
||||
"typescript-eslint": "^8.46.4",
|
||||
"wrangler": "^4.47.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "3.888.0",
|
||||
"@aws-sdk/s3-request-presigner": "3.888.0",
|
||||
"@simplewebauthn/server": "10.0.1",
|
||||
"hono": "^4.10.4",
|
||||
"hono": "^4.10.5",
|
||||
"jsonpath-plus": "^10.3.0",
|
||||
"mimetext": "^3.0.27",
|
||||
"postal-mime": "^2.6.0",
|
||||
"resend": "^4.8.0",
|
||||
"telegraf": "4.16.3",
|
||||
"worker-mailer": "^1.1.5"
|
||||
"worker-mailer": "^1.2.0"
|
||||
},
|
||||
"pnpm": {
|
||||
"patchedDependencies": {
|
||||
|
||||
1032
worker/pnpm-lock.yaml
generated
1032
worker/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -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