fix: 修复邮箱绑定验证错误及多项改进
1. 修复email_verified字段缺失导致的500错误 2. 将邮件主题从"知识管理平台"改为"自动化学习" 3. 增大验证码字体(28->42)和图片尺寸(120x40->160x60) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
45
app.py
45
app.py
@@ -1045,34 +1045,34 @@ def generate_captcha():
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
import io
|
||||
|
||||
# 创建图片
|
||||
width, height = 120, 40
|
||||
# 创建图片 - 增大尺寸以便显示更大的字体
|
||||
width, height = 160, 60
|
||||
image = Image.new('RGB', (width, height), color=(255, 255, 255))
|
||||
draw = ImageDraw.Draw(image)
|
||||
|
||||
# 添加干扰线
|
||||
for _ in range(5):
|
||||
for _ in range(6):
|
||||
x1 = random.randint(0, width)
|
||||
y1 = random.randint(0, height)
|
||||
x2 = random.randint(0, width)
|
||||
y2 = random.randint(0, height)
|
||||
draw.line([(x1, y1), (x2, y2)], fill=(random.randint(0, 200), random.randint(0, 200), random.randint(0, 200)))
|
||||
draw.line([(x1, y1), (x2, y2)], fill=(random.randint(0, 200), random.randint(0, 200), random.randint(0, 200)), width=1)
|
||||
|
||||
# 添加干扰点
|
||||
for _ in range(50):
|
||||
for _ in range(80):
|
||||
x = random.randint(0, width)
|
||||
y = random.randint(0, height)
|
||||
draw.point((x, y), fill=(random.randint(0, 200), random.randint(0, 200), random.randint(0, 200)))
|
||||
|
||||
# 绘制验证码文字
|
||||
# 绘制验证码文字 - 增大字体
|
||||
try:
|
||||
font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 28)
|
||||
font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 42)
|
||||
except:
|
||||
font = ImageFont.load_default()
|
||||
|
||||
for i, char in enumerate(code):
|
||||
x = 10 + i * 25 + random.randint(-3, 3)
|
||||
y = random.randint(2, 8)
|
||||
x = 12 + i * 35 + random.randint(-3, 3)
|
||||
y = random.randint(5, 12)
|
||||
color = (random.randint(0, 150), random.randint(0, 150), random.randint(0, 150))
|
||||
draw.text((x, y), char, font=font, fill=color)
|
||||
|
||||
@@ -2169,7 +2169,8 @@ def run_task(user_id, account_id, browse_type, enable_screenshot=True, source="m
|
||||
# 发送任务完成邮件通知(不截图时在此发送)
|
||||
try:
|
||||
user_info = database.get_user_by_id(user_id)
|
||||
if user_info and user_info.get('email'):
|
||||
# 检查用户是否开启了邮件通知
|
||||
if user_info and user_info.get('email') and database.get_user_email_notify(user_id):
|
||||
account_name = account.remark if account.remark else account.username
|
||||
email_service.send_task_complete_email_async(
|
||||
user_id=user_id,
|
||||
@@ -2538,7 +2539,8 @@ def take_screenshot_for_account(user_id, account_id, browse_type="应读", sourc
|
||||
# 发送任务完成邮件通知
|
||||
try:
|
||||
user_info = database.get_user_by_id(user_id)
|
||||
if user_info and user_info.get('email'):
|
||||
# 检查用户是否开启了邮件通知
|
||||
if user_info and user_info.get('email') and database.get_user_email_notify(user_id):
|
||||
screenshot_path = None
|
||||
if result and result.get('success') and result.get('filename'):
|
||||
screenshot_path = os.path.join(SCREENSHOTS_DIR, result['filename'])
|
||||
@@ -2967,6 +2969,27 @@ def unbind_user_email():
|
||||
return jsonify({"error": "解绑失败"}), 500
|
||||
|
||||
|
||||
@app.route('/api/user/email-notify', methods=['GET'])
|
||||
@login_required
|
||||
def get_user_email_notify():
|
||||
"""获取用户邮件通知偏好"""
|
||||
enabled = database.get_user_email_notify(current_user.id)
|
||||
return jsonify({"enabled": enabled})
|
||||
|
||||
|
||||
@app.route('/api/user/email-notify', methods=['POST'])
|
||||
@login_required
|
||||
def update_user_email_notify():
|
||||
"""更新用户邮件通知偏好"""
|
||||
data = request.get_json()
|
||||
enabled = data.get('enabled', True)
|
||||
|
||||
if database.update_user_email_notify(current_user.id, enabled):
|
||||
return jsonify({"success": True})
|
||||
else:
|
||||
return jsonify({"error": "更新失败"}), 500
|
||||
|
||||
|
||||
@app.route('/api/run_stats', methods=['GET'])
|
||||
@login_required
|
||||
def get_run_stats():
|
||||
|
||||
Reference in New Issue
Block a user