(purchaseId, preserved)
| 2395 | } |
| 2396 | |
| 2397 | async function setLuckmailPurchasePreservedState(purchaseId, preserved) { |
| 2398 | const state = await ensureManualInteractionAllowed('设置 LuckMail 邮箱保留状态'); |
| 2399 | const client = createLuckmailClient(state); |
| 2400 | const purchase = await getLuckmailPurchaseById(state, purchaseId, { |
| 2401 | client, |
| 2402 | projectCode: DEFAULT_LUCKMAIL_PROJECT_CODE, |
| 2403 | }); |
| 2404 | |
| 2405 | if (preserved) { |
| 2406 | const preserveTag = await ensureLuckmailPreserveTag(client, state); |
| 2407 | await client.user.setPurchaseTag(purchase.id, { tagId: preserveTag.id }); |
| 2408 | } else { |
| 2409 | await client.user.setPurchaseTag(purchase.id, { tagId: 0 }); |
| 2410 | } |
| 2411 | |
| 2412 | await addLog(`LuckMail:已将 ${purchase.email_address} ${preserved ? '设为保留' : '取消保留'}`, 'ok'); |
| 2413 | const refreshedState = await getState(); |
| 2414 | const refreshedPurchase = await getLuckmailPurchaseById(refreshedState, purchase.id, { |
| 2415 | client, |
| 2416 | projectCode: DEFAULT_LUCKMAIL_PROJECT_CODE, |
| 2417 | }); |
| 2418 | return buildLuckmailPurchaseView(refreshedPurchase, await getState()); |
| 2419 | } |
| 2420 | |
| 2421 | async function setLuckmailPurchaseDisabledState(purchaseId, disabled) { |
| 2422 | const state = await ensureManualInteractionAllowed(disabled ? '禁用 LuckMail 邮箱' : '启用 LuckMail 邮箱'); |
no test coverage detected