(purchaseId)
| 2370 | } |
| 2371 | |
| 2372 | async function selectLuckmailPurchase(purchaseId) { |
| 2373 | const state = await ensureManualInteractionAllowed('切换 LuckMail 邮箱'); |
| 2374 | const client = createLuckmailClient(state); |
| 2375 | const purchase = await getLuckmailPurchaseById(state, purchaseId, { |
| 2376 | client, |
| 2377 | projectCode: DEFAULT_LUCKMAIL_PROJECT_CODE, |
| 2378 | }); |
| 2379 | |
| 2380 | if (purchase.user_disabled === 1) { |
| 2381 | throw new Error(`LuckMail 邮箱 ${purchase.email_address} 已禁用,无法使用。`); |
| 2382 | } |
| 2383 | |
| 2384 | const aliveResult = await client.user.checkTokenAlive(purchase.token); |
| 2385 | if (!aliveResult?.alive) { |
| 2386 | throw new Error(`LuckMail 邮箱 ${purchase.email_address} 当前不可用:${aliveResult?.message || aliveResult?.status || 'token 已失效'}`); |
| 2387 | } |
| 2388 | |
| 2389 | const activatedPurchase = await activateLuckmailPurchaseForFlow(state, client, purchase, { |
| 2390 | initializeCursor: true, |
| 2391 | logMessage: `LuckMail:已切换当前邮箱为 ${purchase.email_address}`, |
| 2392 | }); |
| 2393 | const nextState = await getState(); |
| 2394 | return buildLuckmailPurchaseView(activatedPurchase, nextState); |
| 2395 | } |
| 2396 | |
| 2397 | async function setLuckmailPurchasePreservedState(purchaseId, preserved) { |
| 2398 | const state = await ensureManualInteractionAllowed('设置 LuckMail 邮箱保留状态'); |
no test coverage detected