mirror of
https://github.com/cnlimiter/codex-register.git
synced 2026-08-28 19:46:37 +08:00
fix(tempmail): 优先使用用户邮箱api获取邮件
This commit is contained in:
@@ -202,16 +202,27 @@ class TempMailService(BaseEmailService):
|
|||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
seen_mail_ids: set = set()
|
seen_mail_ids: set = set()
|
||||||
|
|
||||||
|
# 优先使用用户级 JWT,回退到 admin API
|
||||||
|
cached = self._email_cache.get(email, {})
|
||||||
|
jwt = cached.get("jwt")
|
||||||
|
|
||||||
while time.time() - start_time < timeout:
|
while time.time() - start_time < timeout:
|
||||||
try:
|
try:
|
||||||
# 使用 admin API 查询邮件,通过 address 参数过滤
|
if jwt:
|
||||||
response = self._make_request(
|
response = self._make_request(
|
||||||
"GET",
|
"GET",
|
||||||
"/admin/mails",
|
"/user_api/mails",
|
||||||
params={"limit": 20, "offset": 0, "address": email},
|
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", [])
|
mails = response.get("results", [])
|
||||||
if not isinstance(mails, list):
|
if not isinstance(mails, list):
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
|
|||||||
Reference in New Issue
Block a user