fix: SMTP配额重置使用北京时间
- 添加pytz时区支持 - 配额重置日期改为使用北京时间(UTC+8) - 确保配额在北京时间凌晨0点重置,而不是UTC时间 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,14 @@ import time
|
|||||||
import zipfile
|
import zipfile
|
||||||
import secrets
|
import secrets
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
import pytz
|
||||||
|
|
||||||
|
# 北京时区
|
||||||
|
BEIJING_TZ = pytz.timezone('Asia/Shanghai')
|
||||||
|
|
||||||
|
def get_beijing_today():
|
||||||
|
"""获取北京时间的今天日期字符串"""
|
||||||
|
return datetime.now(BEIJING_TZ).strftime('%Y-%m-%d')
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
from email.mime.multipart import MIMEMultipart
|
from email.mime.multipart import MIMEMultipart
|
||||||
from email.mime.base import MIMEBase
|
from email.mime.base import MIMEBase
|
||||||
@@ -503,7 +511,7 @@ def _get_available_smtp_config(failover: bool = True) -> Optional[Dict[str, Any]
|
|||||||
获取可用的SMTP配置
|
获取可用的SMTP配置
|
||||||
优先级: 主配置 > 按priority排序的启用配置
|
优先级: 主配置 > 按priority排序的启用配置
|
||||||
"""
|
"""
|
||||||
today = datetime.now().strftime('%Y-%m-%d')
|
today = get_beijing_today()
|
||||||
|
|
||||||
with db_pool.get_db() as conn:
|
with db_pool.get_db() as conn:
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
@@ -766,7 +774,7 @@ def send_email(
|
|||||||
|
|
||||||
def _get_next_available_smtp_config(exclude_ids: List[int]) -> Optional[Dict[str, Any]]:
|
def _get_next_available_smtp_config(exclude_ids: List[int]) -> Optional[Dict[str, Any]]:
|
||||||
"""获取下一个可用的SMTP配置(排除已尝试的)"""
|
"""获取下一个可用的SMTP配置(排除已尝试的)"""
|
||||||
today = datetime.now().strftime('%Y-%m-%d')
|
today = get_beijing_today()
|
||||||
|
|
||||||
with db_pool.get_db() as conn:
|
with db_pool.get_db() as conn:
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
|||||||
Reference in New Issue
Block a user