This commit is contained in:
@@ -174,6 +174,16 @@ async def qrcode_status(qrcode_id: str) -> QrStatus:
|
||||
tolerate_ret1=True,
|
||||
)
|
||||
status = str(data.get("status") or "waiting")
|
||||
# 上游用的是 "wait"(不是 "waiting"),扫过之后还有 "scaned"/"confirmed"/"expired";
|
||||
# 这里统一成一套说法,页面只认 waiting/scaned/confirmed/expired。
|
||||
status = {
|
||||
"wait": "waiting",
|
||||
"waiting": "waiting",
|
||||
"scaned": "scaned",
|
||||
"scanned": "scaned",
|
||||
"confirmed": "confirmed",
|
||||
"expired": "expired",
|
||||
}.get(status, status)
|
||||
if status != "confirmed":
|
||||
return QrStatus(status=status)
|
||||
token = _text(data, "bot_token")
|
||||
|
||||
@@ -324,3 +324,14 @@ async def test_stale_token_marks_channel_expired(
|
||||
assert channels["items"][0]["status"] == "expired"
|
||||
assert channels["items"][0]["connected"] is False
|
||||
assert "重新扫码" in channels["items"][0]["last_error"]
|
||||
|
||||
|
||||
async def test_upstream_wait_status_is_normalized(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""上游说 "wait",页面只认 waiting——这一层要对齐,否则界面停在"等扫码结果…"。"""
|
||||
|
||||
async def fake_post(path: str, body: dict, **kwargs: Any) -> dict: # noqa: ARG001
|
||||
return {"status": "wait"}
|
||||
|
||||
monkeypatch.setattr(wechat_ilink, "_post", fake_post)
|
||||
result = await wechat_ilink.qrcode_status("qr-x")
|
||||
assert result.status == "waiting"
|
||||
|
||||
@@ -30,6 +30,7 @@ const ACTION_TEXT: Record<string, string> = {
|
||||
/** 扫码的几种回话,说给用户听的话。 */
|
||||
const QR_TEXT: Record<string, string> = {
|
||||
waiting: "用微信扫这张码,扫完在手机上点确认。",
|
||||
wait: "用微信扫这张码,扫完在手机上点确认。",
|
||||
scaned: "已经扫到了,在手机上点一下「确认登录」。",
|
||||
confirmed: "配好了,现在可以直接在微信里发消息。",
|
||||
expired: "二维码过期了,重新拿一张。",
|
||||
|
||||
Reference in New Issue
Block a user