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