feat: 添加邮件功能第六阶段 - API浏览任务通知
在API模式浏览任务完成时(不截图的情况下),也发送任务完成邮件通知 修改位置: app.py run_browse_task函数 - 在enable_screenshot=False时,浏览成功后发送邮件通知 - 复用email_service.send_task_complete_email_async() 至此邮件功能六个阶段全部完成: 1. 邮件基础设施(多SMTP配置、故障转移) 2. 注册邮箱验证 3. 密码重置邮件 4. 任务完成通知(带截图) 5. 用户邮箱绑定 6. API浏览任务通知 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
18
app.py
18
app.py
@@ -2166,6 +2166,24 @@ def run_task(user_id, account_id, browse_type, enable_screenshot=True, source="m
|
|||||||
duration=int(time_module.time() - task_start_time),
|
duration=int(time_module.time() - task_start_time),
|
||||||
source=source
|
source=source
|
||||||
)
|
)
|
||||||
|
# 发送任务完成邮件通知(不截图时在此发送)
|
||||||
|
try:
|
||||||
|
user_info = database.get_user_by_id(user_id)
|
||||||
|
if user_info and user_info.get('email'):
|
||||||
|
account_name = account.remark if account.remark else account.username
|
||||||
|
email_service.send_task_complete_email_async(
|
||||||
|
user_id=user_id,
|
||||||
|
email=user_info['email'],
|
||||||
|
username=user_info['username'],
|
||||||
|
account_name=account_name,
|
||||||
|
browse_type=browse_type,
|
||||||
|
total_items=result.total_items,
|
||||||
|
total_attachments=result.total_attachments,
|
||||||
|
screenshot_path=None,
|
||||||
|
log_callback=lambda msg: log_to_client(msg, user_id, account_id)
|
||||||
|
)
|
||||||
|
except Exception as email_error:
|
||||||
|
logger.warning(f"发送任务完成邮件失败: {email_error}")
|
||||||
# 成功则跳出重试循环
|
# 成功则跳出重试循环
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user