feat: SMTP配额自动重置(北京时间凌晨0点)
- 添加reset_smtp_daily_quota函数主动重置配额 - 添加定时任务在北京时间00:00自动重置SMTP配额 - 保留被动重置作为备份机制 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -933,6 +933,23 @@ def _update_email_stats(email_type: str, success: bool):
|
||||
conn.commit()
|
||||
|
||||
|
||||
def reset_smtp_daily_quota():
|
||||
"""重置所有SMTP配置的每日发送计数(北京时间凌晨0点调用)"""
|
||||
today = get_beijing_today()
|
||||
with db_pool.get_db() as conn:
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("""
|
||||
UPDATE smtp_configs
|
||||
SET daily_sent = 0, daily_reset_date = ?
|
||||
WHERE daily_reset_date != ? OR daily_reset_date IS NULL OR daily_reset_date = ''
|
||||
""", (today, today))
|
||||
updated = cursor.rowcount
|
||||
conn.commit()
|
||||
if updated > 0:
|
||||
print(f"[邮件服务] 已重置 {updated} 个SMTP配置的每日配额")
|
||||
return updated
|
||||
|
||||
|
||||
def get_email_stats() -> Dict[str, Any]:
|
||||
"""获取邮件统计"""
|
||||
with db_pool.get_db() as conn:
|
||||
|
||||
Reference in New Issue
Block a user