From 5c60ab2977f0aa47b2c372872045a6f9d944133e Mon Sep 17 00:00:00 2001 From: eoao Date: Thu, 4 Sep 2025 01:01:00 +0800 Subject: [PATCH] =?UTF-8?q?=E9=82=AE=E4=BB=B6=E6=8B=92=E6=94=B6=E9=80=80?= =?UTF-8?q?=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mail-worker/src/email/email.js | 40 +++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/mail-worker/src/email/email.js b/mail-worker/src/email/email.js index 89be7e2..b3807fe 100644 --- a/mail-worker/src/email/email.js +++ b/mail-worker/src/email/email.js @@ -35,6 +35,7 @@ export async function email(message, env, ctx) { } = await settingService.query({ env }); if (receive === settingConst.receive.CLOSE) { + message.setReject('Service suspended'); return; } @@ -53,6 +54,7 @@ export async function email(message, env, ctx) { const account = await accountService.selectByEmailIncludeDel({ env: env }, message.to); if (!account && noRecipient === settingConst.noRecipient.CLOSE) { + message.setReject('Recipient not found'); return; } @@ -61,6 +63,7 @@ export async function email(message, env, ctx) { let { banEmail, banEmailType, availDomain } = await roleService.selectByUserId({ env: env }, account.userId); if(!roleService.hasAvailDomainPerm(availDomain, message.to)) { + message.setReject('Mailbox disabled'); return; } @@ -68,7 +71,9 @@ export async function email(message, env, ctx) { if (banEmail.includes('*')) { - return; + + if (!banEmailHandler(banEmailType,message,email)) return + } for (const item of banEmail) { @@ -80,13 +85,7 @@ export async function email(message, env, ctx) { if (banDomain === receiveDomain) { - if (banEmailType === roleConst.banEmailType.ALL) return; - - if (banEmailType === roleConst.banEmailType.CONTENT) { - email.html = 'The content has been deleted'; - email.text = 'The content has been deleted'; - email.attachments = []; - } + if (!banEmailHandler(banEmailType,message,email)) return } @@ -94,13 +93,7 @@ export async function email(message, env, ctx) { if (item.toLowerCase() === email.from.address.toLowerCase()) { - if (banEmailType === roleConst.banEmailType.ALL) return; - - if (banEmailType === roleConst.banEmailType.CONTENT) { - email.html = 'The content has been deleted'; - email.text = 'The content has been deleted'; - email.attachments = []; - } + if (!banEmailHandler(banEmailType,message,email)) return } @@ -227,3 +220,20 @@ ${params.text || emailUtils.htmlToText(params.content) || ''} console.error('邮件接收异常: ', e); } } + +function banEmailHandler(banEmailType,message,email) { + + if (banEmailType === roleConst.banEmailType.ALL) { + message.setReject('Mailbox disabled'); + return false + } + + if (banEmailType === roleConst.banEmailType.CONTENT) { + email.html = 'The content has been deleted'; + email.text = 'The content has been deleted'; + email.attachments = []; + } + + return true + +}