fix: stats loader and smtp daily reset
This commit is contained in:
@@ -304,6 +304,15 @@ def get_smtp_configs(include_password: bool = False) -> List[Dict[str, Any]]:
|
||||
"""获取所有SMTP配置列表"""
|
||||
with db_pool.get_db() as conn:
|
||||
cursor = conn.cursor()
|
||||
# 确保每天的配额在日期切换后能及时重置(即使当天没有触发邮件发送)
|
||||
today = get_beijing_today()
|
||||
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))
|
||||
conn.commit()
|
||||
|
||||
cursor.execute("""
|
||||
SELECT id, name, enabled, is_primary, priority, host, port,
|
||||
username, password, use_ssl, use_tls, sender_name, sender_email,
|
||||
@@ -355,6 +364,14 @@ def get_smtp_config(config_id: int, include_password: bool = False) -> Optional[
|
||||
"""获取单个SMTP配置"""
|
||||
with db_pool.get_db() as conn:
|
||||
cursor = conn.cursor()
|
||||
today = get_beijing_today()
|
||||
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))
|
||||
conn.commit()
|
||||
|
||||
cursor.execute("""
|
||||
SELECT id, name, enabled, is_primary, priority, host, port,
|
||||
username, password, use_ssl, use_tls, sender_name, sender_email,
|
||||
|
||||
Reference in New Issue
Block a user