feat: update verification code recognition logic
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import emailUtils from '../utils/email-utils';
|
||||
import { settingConst } from '../const/entity-const';
|
||||
|
||||
const codeKeywords = ['码', '令牌', 'code', 'token'];
|
||||
|
||||
const aiService = {
|
||||
async extractCode(c, email, options = {}) {
|
||||
if (!this.shouldExtractCode(options.aiCode, options.aiCodeFilter, email)) {
|
||||
@@ -60,19 +58,14 @@ const aiService = {
|
||||
|
||||
const filterList = aiCodeFilterStr ? aiCodeFilterStr.split(',').map(item => item.trim().toLowerCase()).filter(Boolean) : [];
|
||||
|
||||
if (filterList.length > 0) {
|
||||
const fromEmail = (email.from?.address || '').trim().toLowerCase();
|
||||
const fromDomain = emailUtils.getDomain(fromEmail).toLowerCase();
|
||||
return filterList.some(item => item === fromEmail || item === fromDomain);
|
||||
if (filterList.length === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const subject = email.subject || '';
|
||||
const text = emailUtils.formatText(email.text || '');
|
||||
const htmlText = emailUtils.htmlToText(email.html || '');
|
||||
const content = `${subject}\n${htmlText || text}`;
|
||||
const lowerContent = content.toLowerCase();
|
||||
const fromEmail = (email.from?.address || '').trim().toLowerCase();
|
||||
const fromDomain = emailUtils.getDomain(fromEmail).toLowerCase();
|
||||
|
||||
return codeKeywords.some(keyword => lowerContent.includes(keyword));
|
||||
return filterList.some(item => item === fromEmail || item === fromDomain);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user