mirror of
https://github.com/cnlimiter/codex-register.git
synced 2026-05-12 02:21:07 +08:00
Merge branch 'master' into fix/temp-mail-registration-flow
This commit is contained in:
@@ -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