新增站内发送权限

This commit is contained in:
eoao
2026-02-07 08:24:48 +08:00
parent 5da6b44ad6
commit ee1b76cd1b
7 changed files with 28 additions and 34 deletions

View File

@@ -53,7 +53,8 @@ const en = {
botVerifyFail: 'Bot verification failed, please try again',
authExpired: 'Authentication has expired. Please sign in again',
unauthorized: 'Unauthorized',
bannedSend: 'You do not have permission to send emails',
bannedSend: 'You can only send emails to internal mailboxes',
onlyInternalSend: 'Your current role allows sending internal emails only',
noDomainPermAdd: "No permission to add this domain email",
noDomainPermReg: "No permission to register this domain email",
noDomainPermRegKey: "Registration code not valid for this domain",

View File

@@ -53,7 +53,8 @@ const zh = {
botVerifyFail: '人机验证失败,请重试',
authExpired: '身份认证失效,请重新登录',
unauthorized: '权限不足',
bannedSend: '你没有发送邮件权限',
bannedSend: '你没有邮件发送权限',
onlyInternalSend: '权限不足,只能给站内邮箱发件',
noDomainPermAdd: '你没有权限添加该域名邮箱',
noDomainPermReg: '你没有权限注册该域名邮箱',
noDomainPermRegKey: '你的注册码没有权限注册该域名邮箱',

View File

@@ -175,9 +175,24 @@ const emailService = {
const userRow = await userService.selectById(c, userId);
const roleRow = await roleService.selectById(c, userRow.type);
//如果不是管理员,发送被禁用
if (c.env.admin !== userRow.email && roleRow.sendType === 'ban') {
throw new BizError(t('bannedSend'), 403);
//判断接收方是不是全部为站内邮箱
const allInternal = receiveEmail.every(email => {
const domain = '@' + emailUtils.getDomain(email);
return domainList.includes(domain);
});
if (c.env.admin !== userRow.email) {
//发件被禁用
if (roleRow.sendType === 'ban') {
throw new BizError(t('bannedSend'), 403);
}
//发件被禁用
if (roleRow.sendType === 'internal' && !allInternal) {
throw new BizError(t('onlyInternalSend'), 403);
}
}
//如果不是管理员,权限设置了发送次数
@@ -213,12 +228,6 @@ const emailService = {
}
//判断接收方是不是全部为站内邮箱
const allInternal = receiveEmail.every(email => {
const domain = '@' + emailUtils.getDomain(email);
return domainList.includes(domain);
});
const domain = emailUtils.getDomain(accountRow.email);
const resendToken = resendTokens[domain];