feat(config,email_service): Add Cloud Mail API path auto-completion utility

- Add get_cloudmail_api_base() helper function to automatically append /api/public path to EMAIL_API_BASE
- Update create_email_user() to use get_cloudmail_api_base() for consistent API endpoint construction
- Update get_verification_code() to use get_cloudmail_api_base() for email list retrieval
- Update fetch_email_content() to use get_cloudmail_api_base() for email list retrieval
- Refactor telegram_bot.py to use centralized path completion logic instead of inline implementation
- Improve API endpoint consistency across email service operations and reduce code duplication
This commit is contained in:
2026-01-30 15:43:48 +08:00
parent 1c17015669
commit cb55db7901
3 changed files with 22 additions and 5 deletions

View File

@@ -27,6 +27,7 @@ from config import (
get_random_gptmail_domain,
get_next_gptmail_key,
get_gptmail_keys,
get_cloudmail_api_base,
)
from logger import log
@@ -446,7 +447,7 @@ def create_email_user(email: str, password: str = None, role_name: str = None) -
if role_name is None:
role_name = EMAIL_ROLE
url = f"{EMAIL_API_BASE}/addUser"
url = f"{get_cloudmail_api_base()}/addUser"
headers = {
"Authorization": EMAIL_API_AUTH,
"Content-Type": "application/json"
@@ -484,7 +485,7 @@ def get_verification_code(email: str, max_retries: int = None, interval: int = N
Returns:
tuple: (code, error, email_time) - 验证码、错误信息、邮件时间
"""
url = f"{EMAIL_API_BASE}/emailList"
url = f"{get_cloudmail_api_base()}/emailList"
headers = {
"Authorization": EMAIL_API_AUTH,
"Content-Type": "application/json"
@@ -565,7 +566,7 @@ def fetch_email_content(email: str) -> list:
Returns:
list: 邮件列表
"""
url = f"{EMAIL_API_BASE}/emailList"
url = f"{get_cloudmail_api_base()}/emailList"
headers = {
"Authorization": EMAIL_API_AUTH,
"Content-Type": "application/json"