diff --git a/app.py b/app.py index 8e2bae7..6ec21dc 100755 --- a/app.py +++ b/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), 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 else: