mirror of
https://github.com/cnlimiter/codex-register.git
synced 2026-06-26 09:42:03 +08:00
Merge branch 'master' into fix/temp-mail-registration-flow
This commit is contained in:
@@ -12,13 +12,13 @@ from .base import (
|
||||
)
|
||||
from .tempmail import TempmailService
|
||||
from .outlook import OutlookService
|
||||
from .custom_domain import CustomDomainEmailService
|
||||
from .moe_mail import MeoMailEmailService
|
||||
from .temp_mail import TempMailService
|
||||
|
||||
# 注册服务
|
||||
EmailServiceFactory.register(EmailServiceType.TEMPMAIL, TempmailService)
|
||||
EmailServiceFactory.register(EmailServiceType.OUTLOOK, OutlookService)
|
||||
EmailServiceFactory.register(EmailServiceType.CUSTOM_DOMAIN, CustomDomainEmailService)
|
||||
EmailServiceFactory.register(EmailServiceType.CUSTOM_DOMAIN, MeoMailEmailService)
|
||||
EmailServiceFactory.register(EmailServiceType.TEMP_MAIL, TempMailService)
|
||||
|
||||
# 导出 Outlook 模块的额外内容
|
||||
@@ -48,7 +48,7 @@ __all__ = [
|
||||
# 服务类
|
||||
'TempmailService',
|
||||
'OutlookService',
|
||||
'CustomDomainEmailService',
|
||||
'MeoMailEmailService',
|
||||
'TempMailService',
|
||||
# Outlook 模块
|
||||
'ProviderType',
|
||||
|
||||
@@ -18,7 +18,7 @@ from ..config.constants import OTP_CODE_PATTERN
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class CustomDomainEmailService(BaseEmailService):
|
||||
class MeoMailEmailService(BaseEmailService):
|
||||
"""
|
||||
自定义域名邮箱服务
|
||||
基于 REST API 接口
|
||||
@@ -298,16 +298,27 @@ class TempMailService(BaseEmailService):
|
||||
start_time = time.time()
|
||||
seen_mail_ids: set = set()
|
||||
|
||||
# 优先使用用户级 JWT,回退到 admin API
|
||||
cached = self._email_cache.get(email, {})
|
||||
jwt = cached.get("jwt")
|
||||
|
||||
while time.time() - start_time < timeout:
|
||||
try:
|
||||
# 使用 admin API 查询邮件,通过 address 参数过滤
|
||||
response = self._make_request(
|
||||
"GET",
|
||||
"/admin/mails",
|
||||
params={"limit": 20, "offset": 0, "address": email},
|
||||
)
|
||||
if jwt:
|
||||
response = self._make_request(
|
||||
"GET",
|
||||
"/user_api/mails",
|
||||
params={"limit": 20, "offset": 0},
|
||||
headers={"x-user-token": jwt, "Content-Type": "application/json", "Accept": "application/json"},
|
||||
)
|
||||
else:
|
||||
response = self._make_request(
|
||||
"GET",
|
||||
"/admin/mails",
|
||||
params={"limit": 20, "offset": 0, "address": email},
|
||||
)
|
||||
|
||||
# admin/mails 返回格式: {"results": [...], "total": N}
|
||||
# /user_api/mails 和 /admin/mails 返回格式相同: {"results": [...], "total": N}
|
||||
mails = response.get("results", [])
|
||||
if not isinstance(mails, list):
|
||||
time.sleep(3)
|
||||
|
||||
Reference in New Issue
Block a user