fix: delete expired email on read path to ensure 24h retention

This commit is contained in:
zimk
2026-02-27 15:09:35 +08:00
parent 2fffc85720
commit 0d81fbaae0

View File

@@ -64,6 +64,10 @@ export default {
if (!row) return json(null);
if (Date.now() - row.received_at > ONE_DAY_MS) {
// 读取时发现过期,立即删除,避免库里长期残留
await env.DB.prepare(
`DELETE FROM latest_emails WHERE recipient = ? AND received_at = ?`
).bind(row.recipient, row.received_at).run();
return json(null);
}