(purchaseId, disabled)
| 2419 | } |
| 2420 | |
| 2421 | async function setLuckmailPurchaseDisabledState(purchaseId, disabled) { |
| 2422 | const state = await ensureManualInteractionAllowed(disabled ? '禁用 LuckMail 邮箱' : '启用 LuckMail 邮箱'); |
| 2423 | const client = createLuckmailClient(state); |
| 2424 | const purchase = await getLuckmailPurchaseById(state, purchaseId, { |
| 2425 | client, |
| 2426 | projectCode: DEFAULT_LUCKMAIL_PROJECT_CODE, |
| 2427 | }); |
| 2428 | |
| 2429 | await client.user.setPurchaseDisabled(purchase.id, disabled ? 1 : 0); |
| 2430 | |
| 2431 | const currentPurchase = getCurrentLuckmailPurchase(await getState()); |
| 2432 | if (disabled && currentPurchase?.id === purchase.id) { |
| 2433 | await clearLuckmailRuntimeState({ clearEmail: isLuckmailProvider(await getState()) }); |
| 2434 | } |
| 2435 | |
| 2436 | await addLog(`LuckMail:已将 ${purchase.email_address} ${disabled ? '禁用' : '启用'}`, 'ok'); |
| 2437 | const refreshedState = await getState(); |
| 2438 | const refreshedPurchase = await getLuckmailPurchaseById(refreshedState, purchase.id, { |
| 2439 | client, |
| 2440 | projectCode: DEFAULT_LUCKMAIL_PROJECT_CODE, |
| 2441 | }); |
| 2442 | return buildLuckmailPurchaseView(refreshedPurchase, await getState()); |
| 2443 | } |
| 2444 | |
| 2445 | async function batchUpdateLuckmailPurchases(input = {}) { |
| 2446 | const action = String(input.action || '').trim(); |
no test coverage detected