新增站内发送权限

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

@@ -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];