Merge branch 'dev' into main
This commit is contained in:
@@ -344,6 +344,7 @@ const en = {
|
||||
clientId: 'Client ID',
|
||||
clientSecret: 'Client Secret',
|
||||
callbackBase: 'https://domain',
|
||||
notOwner: 'Base email does not belong to you',
|
||||
}
|
||||
|
||||
export default en
|
||||
|
||||
@@ -344,5 +344,6 @@ const zh = {
|
||||
clientId: '客户端 ID',
|
||||
clientSecret: '客户端密钥',
|
||||
callbackBase: 'https://domain',
|
||||
notOwner: '基础邮箱不属于您',
|
||||
}
|
||||
export default zh
|
||||
|
||||
@@ -496,10 +496,8 @@ function submit() {
|
||||
plain: true
|
||||
})
|
||||
verifyShow.value = false
|
||||
showAdd.value = false
|
||||
userStore.refreshUserInfo()
|
||||
nextTick(() => {
|
||||
addRef.value.focus()
|
||||
})
|
||||
}).catch(res => {
|
||||
if (res.code === 400) {
|
||||
verifyToken = ''
|
||||
|
||||
@@ -158,6 +158,7 @@
|
||||
<el-input v-model="addForm.email" type="text" :placeholder="$t('emailAccount')" autocomplete="off" @keyup.enter="submit">
|
||||
<template #append>
|
||||
<div @click.stop="openSelect">
|
||||
<div inert>
|
||||
<el-select
|
||||
ref="mySelect"
|
||||
v-model="addForm.suffix"
|
||||
@@ -171,6 +172,7 @@
|
||||
:value="item"
|
||||
/>
|
||||
</el-select>
|
||||
</div>
|
||||
<div>
|
||||
<span>{{ addForm.suffix }}</span>
|
||||
<Icon class="setting-icon" icon="mingcute:down-small-fill" width="20" height="20"/>
|
||||
@@ -682,8 +684,6 @@ const openSelect = () => {
|
||||
|
||||
function resetAddForm() {
|
||||
addForm.email = ''
|
||||
addForm.suffix = settingStore.domainList[0]
|
||||
addForm.type = null
|
||||
addForm.password = ''
|
||||
}
|
||||
|
||||
@@ -745,7 +745,7 @@ function submit() {
|
||||
form.email = form.email + form.suffix
|
||||
userAdd(form).then(() => {
|
||||
addLoading.value = false
|
||||
addForm.email = ''
|
||||
showAdd.value = false
|
||||
ElMessage({
|
||||
message: t('addSuccessMsg'),
|
||||
type: "success",
|
||||
|
||||
@@ -57,7 +57,14 @@ export async function email(message, env, ctx) {
|
||||
return;
|
||||
}
|
||||
|
||||
const account = await accountService.selectByEmailIncludeDel({ env: env }, message.to);
|
||||
let account = await accountService.selectByEmailIncludeDel({ env: env }, message.to);
|
||||
|
||||
if (!account) {
|
||||
const baseEmail = emailUtils.getBaseEmail(message.to);
|
||||
if (baseEmail && baseEmail !== message.to) {
|
||||
account = await accountService.selectByEmailIncludeDel({ env: env }, baseEmail);
|
||||
}
|
||||
}
|
||||
|
||||
if (!account && noRecipient === settingConst.noRecipient.CLOSE) {
|
||||
message.setReject('Recipient not found');
|
||||
|
||||
@@ -57,6 +57,14 @@ const accountService = {
|
||||
throw new BizError(t('isRegAccount'));
|
||||
}
|
||||
|
||||
if (email.includes('+')) {
|
||||
const baseEmail = emailUtils.getBaseEmail(email);
|
||||
const baseAccount = await this.selectByEmailIncludeDel(c, baseEmail);
|
||||
if (!baseAccount || baseAccount.userId !== userId) {
|
||||
throw new BizError(t('notOwner'));
|
||||
}
|
||||
}
|
||||
|
||||
const userRow = await userService.selectById(c, userId);
|
||||
const roleRow = await roleService.selectById(c, userRow.type);
|
||||
|
||||
|
||||
@@ -561,8 +561,29 @@ const emailService = {
|
||||
//查询所有收件人账号信息
|
||||
let accountList = await orm(c).select().from(account).where(inArray(account.email, receiveEmail)).all();
|
||||
|
||||
// 对于含+未精确匹配的收件人,获取基础地址账号
|
||||
const plusEmails = receiveEmail.filter(
|
||||
e => e.includes('+') && !accountList.some(a => a.email === e)
|
||||
);
|
||||
const baseAccounts = [];
|
||||
if (plusEmails.length > 0) {
|
||||
const baseEmails = [...new Set(
|
||||
plusEmails.map(e => emailUtils.getBaseEmail(e)).filter(Boolean)
|
||||
)];
|
||||
const existing = new Set(accountList.map(a => a.email));
|
||||
const needed = baseEmails.filter(e => !existing.has(e));
|
||||
if (needed.length > 0) {
|
||||
const rows = await orm(c).select().from(account)
|
||||
.where(inArray(account.email, needed)).all();
|
||||
baseAccounts.push(...rows);
|
||||
}
|
||||
}
|
||||
|
||||
// 合并精确匹配和基础地址匹配的账号用于权限查询
|
||||
const allAccounts = [...accountList, ...baseAccounts];
|
||||
|
||||
//查询所有收件人权限身份
|
||||
const userIds = accountList.map(accountRow => accountRow.userId);
|
||||
const userIds = allAccounts.map(accountRow => accountRow.userId);
|
||||
let roleList = await roleService.selectByUserIds(c, userIds);
|
||||
|
||||
//封装数据库准备保存到数据库
|
||||
@@ -578,7 +599,13 @@ const emailService = {
|
||||
emailValues.toName = emailUtils.getName(email);
|
||||
emailValues.emailId = null;
|
||||
|
||||
const accountRow = accountList.find(accountRow => accountRow.email === email);
|
||||
let accountRow = allAccounts.find(accountRow => accountRow.email === email);
|
||||
|
||||
// 精确匹配不到时回退到主地址(去掉 +tag)
|
||||
if (!accountRow && email.includes('+')) {
|
||||
const baseEmail = emailUtils.getBaseEmail(email);
|
||||
accountRow = allAccounts.find(accountRow => accountRow.email === baseEmail);
|
||||
}
|
||||
|
||||
//如果收件人存在就把邮件信息改成收件人的
|
||||
if (accountRow) {
|
||||
|
||||
@@ -14,6 +14,13 @@ const emailUtils = {
|
||||
return parts.length === 2 ? parts[0] : '';
|
||||
},
|
||||
|
||||
getBaseEmail(email) {
|
||||
const parts = email.split('@');
|
||||
if (parts.length !== 2) return '';
|
||||
const localPart = parts[0].split('+')[0];
|
||||
return localPart + '@' + parts[1];
|
||||
},
|
||||
|
||||
formatText(text) {
|
||||
if (!text) return ''
|
||||
return text
|
||||
|
||||
Reference in New Issue
Block a user