From 12e6225ebab4756cd820b62058c868ef2965794a Mon Sep 17 00:00:00 2001 From: QLHazyCoder <2825305047@qq.com> Date: Sat, 25 Apr 2026 20:14:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=20Cloudflare=20?= =?UTF-8?q?=E4=B8=B4=E6=97=B6=E9=82=AE=E7=AE=B1=E5=A4=84=E7=90=86=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=AF=B9=E9=82=AE=E7=AE=B1?= =?UTF-8?q?=E6=8F=90=E4=BE=9B=E8=80=85=E5=92=8C=E7=94=9F=E6=88=90=E5=99=A8?= =?UTF-8?q?=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- background.js | 6 +++- tests/cloudflare-temp-email-provider.test.js | 30 ++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/background.js b/background.js index 19743ac..b5767be 100644 --- a/background.js +++ b/background.js @@ -931,7 +931,11 @@ function normalizeCloudflareTempEmailReceiveMailbox(value = '') { function resolveCloudflareTempEmailPollTargetEmail(state = {}, pollPayload = {}, config = getCloudflareTempEmailConfig(state)) { const configuredReceiveMailbox = normalizeCloudflareTempEmailReceiveMailbox(config.receiveMailbox); - if (configuredReceiveMailbox) { + const mailProvider = String(state?.mailProvider || '').trim().toLowerCase(); + const emailGenerator = String(state?.emailGenerator || '').trim().toLowerCase(); + const shouldPreferConfiguredReceiveMailbox = mailProvider === 'cloudflare-temp-email' + && emailGenerator !== 'cloudflare-temp-email'; + if (shouldPreferConfiguredReceiveMailbox && configuredReceiveMailbox) { return configuredReceiveMailbox; } diff --git a/tests/cloudflare-temp-email-provider.test.js b/tests/cloudflare-temp-email-provider.test.js index 845c954..57d1baf 100644 --- a/tests/cloudflare-temp-email-provider.test.js +++ b/tests/cloudflare-temp-email-provider.test.js @@ -172,6 +172,8 @@ test('pollCloudflareTempEmailVerificationCode prefers configured receive mailbox const result = await api.pollCloudflareTempEmailVerificationCode(4, { email: 'duck-forwarded@duck.com', + mailProvider: 'cloudflare-temp-email', + emailGenerator: 'duck', cloudflareTempEmailReceiveMailbox: 'forward-box@email.20021108.xyz', }, { targetEmail: 'duck-forwarded@duck.com', @@ -182,3 +184,31 @@ test('pollCloudflareTempEmailVerificationCode prefers configured receive mailbox assert.equal(result.code, '654321'); assert.deepEqual(api.snapshot().listCalls, ['forward-box@email.20021108.xyz']); }); + +test('pollCloudflareTempEmailVerificationCode ignores stale receive mailbox when the field should be hidden', async () => { + const api = createProviderApi({ + receiveMailbox: 'forward-box@email.20021108.xyz', + messages: [{ + id: 'mail-3', + address: 'generated@email.20021108.xyz', + receivedDateTime: '2026-04-13T11:20:00.000Z', + subject: 'Signup verification code', + from: { emailAddress: { address: 'noreply@tm.openai.com' } }, + bodyPreview: 'Your verification code is 246810.', + }], + }); + + const result = await api.pollCloudflareTempEmailVerificationCode(4, { + email: 'generated@email.20021108.xyz', + mailProvider: 'cloudflare-temp-email', + emailGenerator: 'cloudflare-temp-email', + cloudflareTempEmailReceiveMailbox: 'forward-box@email.20021108.xyz', + }, { + targetEmail: 'generated@email.20021108.xyz', + maxAttempts: 1, + intervalMs: 1, + }); + + assert.equal(result.code, '246810'); + assert.deepEqual(api.snapshot().listCalls, ['generated@email.20021108.xyz']); +});