You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.1 KiB
45 lines
1.1 KiB
/**
|
|
* 手动清理已关闭自动过期删除。
|
|
* 默认拒绝执行;仅 --force 时按 DATA_RETENTION_DAYS 删除过期邮件。
|
|
* 日常请在列表里勾选删除,或满 1000 封时按弹窗处理。
|
|
*/
|
|
import { getEnv, resetEnvCache } from "../src/lib/env";
|
|
import { runDataRetentionCleanup } from "../src/services/retention/cleanup";
|
|
|
|
async function main() {
|
|
resetEnvCache();
|
|
const force = process.argv.includes("--force");
|
|
const dryRun = process.argv.includes("--dry-run");
|
|
if (!force) {
|
|
console.log(
|
|
JSON.stringify(
|
|
{
|
|
skipped: true,
|
|
reason: "auto retention disabled; pass --force to run DATA_RETENTION_DAYS cleanup",
|
|
},
|
|
null,
|
|
2,
|
|
),
|
|
);
|
|
return;
|
|
}
|
|
const env = getEnv();
|
|
console.log(
|
|
JSON.stringify(
|
|
{
|
|
DATA_RETENTION_DAYS: env.DATA_RETENTION_DAYS,
|
|
dryRun,
|
|
},
|
|
null,
|
|
2,
|
|
),
|
|
);
|
|
const stats = await runDataRetentionCleanup({ dryRun });
|
|
console.log(JSON.stringify(stats, null, 2));
|
|
}
|
|
|
|
main().catch((e) => {
|
|
console.error(e);
|
|
process.exit(1);
|
|
});
|