Skip to content
This repository was archived by the owner on Apr 22, 2026. It is now read-only.

Commit 2e3e179

Browse files
committed
release(v1.0.8): 优化 Graph 接口模式账号列表拉取
优先走 /api/open/accounts 开放列表接口,移除 /api/open/messages 预探测导致的慢路径;对未登录/会话过期返回快速失败提示。 Refs #7
1 parent e9eb0e1 commit 2e3e179

3 files changed

Lines changed: 16 additions & 14 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ CodeX Register 是一个本地桌面化控制台,用于统一执行注册流
1010

1111
## 0. 更新日志
1212

13+
### v1.0.8 (2026-04-06)
14+
15+
- Issue: #7 — Graph 接口模式账号列表拉取优化。
16+
- 优先使用开放列表接口 `GET /api/open/accounts`,避免预探测 `/api/open/messages` 造成取件级慢请求。
17+
- 当上游返回未登录/会话过期时快速失败并给出明确提示,不再继续慢速扫描。
18+
1319
### v1.0.7 (2026-04-06)
1420

1521
- Graph 接口模式账号备注更新切换为开放接口:`PATCH /api/open/accounts/:id/remark`

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.7
1+
1.0.8

codex_register/mail_services.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2564,19 +2564,6 @@ def _discover_api_accounts_by_id_scan(self, *, proxies: Any = None) -> list[dict
25642564
return rows
25652565

25662566
def _load_accounts_from_api(self, *, proxies: Any = None) -> list[dict[str, Any]]:
2567-
pre_status, pre_payload, pre_text = self._api_request(
2568-
"POST",
2569-
"/api/open/messages",
2570-
json_body={"id": 1},
2571-
proxies=proxies,
2572-
timeout=max(5, int(round(self._api_scan_req_timeout))),
2573-
)
2574-
if self._is_api_token_invalid(pre_status, pre_payload, pre_text):
2575-
raise MailServiceError(
2576-
"Graph 接口模式鉴权失败:开放接口 token 无效。"
2577-
"请填写上游 MAIL_API_TOKEN(不是后台登录密码)。"
2578-
)
2579-
25802567
paths = [
25812568
"/api/open/accounts",
25822569
"/api/open/accounts/list",
@@ -2585,6 +2572,7 @@ def _load_accounts_from_api(self, *, proxies: Any = None) -> list[dict[str, Any]
25852572
"/api/open/mailbox/list",
25862573
]
25872574
last_err = ""
2575+
login_required_hit = False
25882576
for path in paths:
25892577
status, payload, text = self._api_request("GET", path, proxies=proxies, timeout=30)
25902578
if status == 404:
@@ -2598,6 +2586,7 @@ def _load_accounts_from_api(self, *, proxies: Any = None) -> list[dict[str, Any]
25982586
)
25992587
last_err = f"{path} HTTP {status}: {err_detail or text}"
26002588
if self._is_api_login_required(status, payload, text):
2589+
login_required_hit = True
26012590
break
26022591
continue
26032592

@@ -2620,6 +2609,13 @@ def _load_accounts_from_api(self, *, proxies: Any = None) -> list[dict[str, Any]
26202609
return rows
26212610
last_err = f"{path} 返回成功但未包含可用账号列表"
26222611

2612+
if login_required_hit:
2613+
raise MailServiceError(
2614+
"Graph 接口模式拉取账号列表失败:上游返回未登录或会话过期。"
2615+
"请确认已调用开放接口 /api/open/accounts,"
2616+
"并使用 MAIL_API_TOKEN(或 INGEST_TOKEN 回退)进行鉴权。"
2617+
)
2618+
26232619
scanned_rows = self._discover_api_accounts_by_id_scan(proxies=proxies)
26242620
if scanned_rows:
26252621
self._api_accounts_discovered_by_scan = True

0 commit comments

Comments
 (0)