(state, client)
| 2335 | } |
| 2336 | |
| 2337 | async function findReusableLuckmailPurchaseForFlow(state, client) { |
| 2338 | const preserveTagInfo = getLuckmailPreserveTagInfo(state); |
| 2339 | const reusablePurchases = filterReusableLuckmailPurchases( |
| 2340 | await listLuckmailPurchasesByProject(state, { |
| 2341 | client, |
| 2342 | projectCode: DEFAULT_LUCKMAIL_PROJECT_CODE, |
| 2343 | }), |
| 2344 | { |
| 2345 | projectCode: DEFAULT_LUCKMAIL_PROJECT_CODE, |
| 2346 | usedPurchases: getLuckmailUsedPurchases(state), |
| 2347 | preserveTagId: preserveTagInfo.id, |
| 2348 | preserveTagName: preserveTagInfo.name, |
| 2349 | now: Date.now(), |
| 2350 | } |
| 2351 | ); |
| 2352 | |
| 2353 | for (const candidate of reusablePurchases) { |
| 2354 | try { |
| 2355 | const aliveResult = await client.user.checkTokenAlive(candidate.token); |
| 2356 | if (!aliveResult?.alive) { |
| 2357 | await addLog( |
| 2358 | `LuckMail:跳过不可复用邮箱 ${candidate.email_address}:${aliveResult?.message || aliveResult?.status || 'token 不可用'}`, |
| 2359 | 'warn' |
| 2360 | ); |
| 2361 | continue; |
| 2362 | } |
| 2363 | return candidate; |
| 2364 | } catch (err) { |
| 2365 | await addLog(`LuckMail:检测复用邮箱 ${candidate.email_address} 失败:${err.message}`, 'warn'); |
| 2366 | } |
| 2367 | } |
| 2368 | |
| 2369 | return null; |
| 2370 | } |
| 2371 | |
| 2372 | async function selectLuckmailPurchase(purchaseId) { |
| 2373 | const state = await ensureManualInteractionAllowed('切换 LuckMail 邮箱'); |
no test coverage detected