Compare commits

...
2 Commits
Author SHA1 Message Date
Dream Hunter 09a6cac8fe feat: upgrade dependencies (#740) 2025-10-12 13:47:40 +08:00
Dream HunterandClaude 5f752c94f9 feat: add cleanup for unbound addresses feature (#739)
- Add unboundAddress cleanup type to backend cleanup logic
- Update CleanupSettings model with unbound address fields
- Add scheduled task for automatic unbound address cleanup
- Add UI controls in admin Maintenance panel for manual cleanup
- Add i18n support (en/zh) for unbound address cleanup labels
- Clean addresses not bound to any user created before n days

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-12 13:46:13 +08:00
11 changed files with 1188 additions and 1160 deletions
+2 -2
View File
@@ -29,7 +29,7 @@
"jszip": "^3.10.1", "jszip": "^3.10.1",
"mail-parser-wasm": "^0.2.1", "mail-parser-wasm": "^0.2.1",
"naive-ui": "^2.43.1", "naive-ui": "^2.43.1",
"postal-mime": "^2.4.4", "postal-mime": "^2.5.0",
"vooks": "^0.2.12", "vooks": "^0.2.12",
"vue": "^3.5.22", "vue": "^3.5.22",
"vue-clipboard3": "^2.0.0", "vue-clipboard3": "^2.0.0",
@@ -48,7 +48,7 @@
"vite-plugin-wasm": "^3.5.0", "vite-plugin-wasm": "^3.5.0",
"workbox-build": "^7.3.0", "workbox-build": "^7.3.0",
"workbox-window": "^7.3.0", "workbox-window": "^7.3.0",
"wrangler": "^4.40.1" "wrangler": "^4.42.2"
}, },
"packageManager": "pnpm@10.10.0+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39" "packageManager": "pnpm@10.10.0+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39"
} }
+270 -263
View File
File diff suppressed because it is too large Load Diff
+16
View File
@@ -17,6 +17,8 @@ const cleanupModel = ref({
cleanAddressDays: 30, cleanAddressDays: 30,
enableInactiveAddressAutoCleanup: false, enableInactiveAddressAutoCleanup: false,
cleanInactiveAddressDays: 30, cleanInactiveAddressDays: 30,
enableUnboundAddressAutoCleanup: false,
cleanUnboundAddressDays: 30,
}) })
const { t } = useI18n({ const { t } = useI18n({
@@ -28,6 +30,7 @@ const { t } = useI18n({
sendBoxLabel: "Cleanup the sendbox before n days", sendBoxLabel: "Cleanup the sendbox before n days",
addressCreateLabel: "Cleanup the address created before n days", addressCreateLabel: "Cleanup the address created before n days",
inactiveAddressLabel: "Cleanup the inactive address before n days", inactiveAddressLabel: "Cleanup the inactive address before n days",
unboundAddressLabel: "Cleanup the unbound address before n days",
cleanupNow: "Cleanup now", cleanupNow: "Cleanup now",
autoCleanup: "Auto cleanup", autoCleanup: "Auto cleanup",
cleanupSuccess: "Cleanup success", cleanupSuccess: "Cleanup success",
@@ -41,6 +44,7 @@ const { t } = useI18n({
sendBoxLabel: "清理 n 天前的发件箱", sendBoxLabel: "清理 n 天前的发件箱",
addressCreateLabel: "清理 n 天前创建的地址", addressCreateLabel: "清理 n 天前创建的地址",
inactiveAddressLabel: "清理 n 天前的未活跃地址", inactiveAddressLabel: "清理 n 天前的未活跃地址",
unboundAddressLabel: "清理 n 天前的未绑定用户地址",
autoCleanup: "自动清理", autoCleanup: "自动清理",
cleanupSuccess: "清理成功", cleanupSuccess: "清理成功",
cleanupNow: "立即清理", cleanupNow: "立即清理",
@@ -161,6 +165,18 @@ onMounted(async () => {
{{ t('cleanupNow') }} {{ t('cleanupNow') }}
</n-button> </n-button>
</n-form-item-row> </n-form-item-row>
<n-form-item-row :label="t('unboundAddressLabel')">
<n-checkbox v-model:checked="cleanupModel.enableUnboundAddressAutoCleanup">
{{ t('autoCleanup') }}
</n-checkbox>
<n-input-number v-model:value="cleanupModel.cleanUnboundAddressDays" :placeholder="t('tip')" />
<n-button @click="cleanup('unboundAddress', cleanupModel.cleanUnboundAddressDays)">
<template #icon>
<n-icon :component="CleaningServicesFilled" />
</template>
{{ t('cleanupNow') }}
</n-button>
</n-form-item-row>
</n-form> </n-form>
</n-card> </n-card>
</div> </div>
+1 -1
View File
@@ -11,7 +11,7 @@
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"devDependencies": { "devDependencies": {
"wrangler": "^4.40.1" "wrangler": "^4.42.2"
}, },
"packageManager": "pnpm@10.10.0+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39" "packageManager": "pnpm@10.10.0+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39"
} }
+2 -2
View File
@@ -4,9 +4,9 @@
"version": "1.0.6", "version": "1.0.6",
"type": "module", "type": "module",
"devDependencies": { "devDependencies": {
"@types/node": "^24.5.2", "@types/node": "^24.7.2",
"vitepress": "^1.6.4", "vitepress": "^1.6.4",
"wrangler": "^4.40.1" "wrangler": "^4.42.2"
}, },
"scripts": { "scripts": {
"dev": "vitepress dev docs", "dev": "vitepress dev docs",
+283 -283
View File
File diff suppressed because it is too large Load Diff
+6 -6
View File
@@ -11,23 +11,23 @@
"build": "wrangler deploy --dry-run --outdir dist --minify" "build": "wrangler deploy --dry-run --outdir dist --minify"
}, },
"devDependencies": { "devDependencies": {
"@cloudflare/workers-types": "^4.20250926.0", "@cloudflare/workers-types": "^4.20251011.0",
"@eslint/js": "9.18.0", "@eslint/js": "9.18.0",
"@simplewebauthn/types": "10.0.0", "@simplewebauthn/types": "10.0.0",
"@types/node": "^22.18.6", "@types/node": "^22.18.10",
"eslint": "9.18.0", "eslint": "9.18.0",
"globals": "^15.15.0", "globals": "^15.15.0",
"typescript-eslint": "^8.44.1", "typescript-eslint": "^8.46.0",
"wrangler": "^4.40.1" "wrangler": "^4.42.2"
}, },
"dependencies": { "dependencies": {
"@aws-sdk/client-s3": "3.888.0", "@aws-sdk/client-s3": "3.888.0",
"@aws-sdk/s3-request-presigner": "3.888.0", "@aws-sdk/s3-request-presigner": "3.888.0",
"@simplewebauthn/server": "10.0.1", "@simplewebauthn/server": "10.0.1",
"hono": "^4.9.8", "hono": "^4.9.11",
"jsonpath-plus": "^10.3.0", "jsonpath-plus": "^10.3.0",
"mimetext": "^3.0.27", "mimetext": "^3.0.27",
"postal-mime": "^2.4.4", "postal-mime": "^2.5.0",
"resend": "^4.8.0", "resend": "^4.8.0",
"telegraf": "4.16.3", "telegraf": "4.16.3",
"worker-mailer": "^1.1.5" "worker-mailer": "^1.1.5"
+593 -603
View File
File diff suppressed because it is too large Load Diff
+6
View File
@@ -251,6 +251,12 @@ export const cleanup = async (
`created_at < datetime('now', '-${cleanDays} day')` `created_at < datetime('now', '-${cleanDays} day')`
) )
break; break;
case "unboundAddress":
await batchDeleteAddressWithData(
c,
`id NOT IN (SELECT address_id FROM users_address) AND created_at < datetime('now', '-${cleanDays} day')`
)
break;
case "mails": case "mails":
await c.env.DB.prepare(` await c.env.DB.prepare(`
DELETE FROM raw_mails WHERE created_at < datetime('now', '-${cleanDays} day')` DELETE FROM raw_mails WHERE created_at < datetime('now', '-${cleanDays} day')`
+2
View File
@@ -46,6 +46,8 @@ export type CleanupSettings = {
cleanAddressDays: number; cleanAddressDays: number;
enableInactiveAddressAutoCleanup: boolean | undefined; enableInactiveAddressAutoCleanup: boolean | undefined;
cleanInactiveAddressDays: number; cleanInactiveAddressDays: number;
enableUnboundAddressAutoCleanup: boolean | undefined;
cleanUnboundAddressDays: number;
} }
export class GeoData { export class GeoData {
+7
View File
@@ -50,4 +50,11 @@ export async function scheduled(event: ScheduledEvent, env: Bindings, ctx: any)
autoCleanupSetting.cleanAddressDays autoCleanupSetting.cleanAddressDays
); );
} }
if (autoCleanupSetting.enableUnboundAddressAutoCleanup) {
await cleanup(
{ env: env, } as Context<HonoCustomType>,
"unboundAddress",
autoCleanupSetting.cleanUnboundAddressDays
);
}
} }