修复星标不能查看,附件等多个bug,优化样式

This commit is contained in:
eoao
2025-06-05 23:09:05 +08:00
parent cdcd22962f
commit 1c40dc8338
13 changed files with 74 additions and 42 deletions

View File

@@ -5,7 +5,7 @@ import settingService from '../service/setting-service';
import attService from '../service/att-service';
import constant from '../const/constant';
import fileUtils from '../utils/file-utils';
import { emailConst, isDel } from '../const/entity-const';
import {attConst, emailConst, isDel} from '../const/entity-const';
export async function email(message, env, ctx) {
@@ -60,6 +60,7 @@ export async function email(message, env, ctx) {
attachment.emailId = emailRow.emailId;
attachment.userId = emailRow.userId;
attachment.accountId = emailRow.accountId;
attachment.type = attachment.contentId ? attConst.type.EMBED : attConst.type.ATT
})
if (attachments.length > 0) {

View File

@@ -46,11 +46,9 @@ const accountService = {
const userRow = await userService.selectById(c, userId);
const roleRow = await roleService.selectById(c, userRow.type);
if (roleRow.accountCount) {
if (roleRow.accountCount && userRow.email !== c.env.admin) {
const userAccountCount = await accountService.countUserAccount(c, userId)
if(userAccountCount >= roleRow.accountCount) throw new BizError(`添加邮箱数量限制${roleRow.accountCount}`, 403);
}
if (await settingService.isAddEmailVerify(c)) {

View File

@@ -154,7 +154,12 @@ const attService = {
},
selectByEmailIds(c, emailIds) {
return orm(c).select().from(att).where(and(inArray(att.emailId,emailIds),eq(att.type, attConst.type.ATT))).all();
return orm(c).select().from(att).where(
and(
inArray(att.emailId,emailIds),
eq(att.type, attConst.type.ATT),
isNull(att.contentId)))
.all();
}
};

View File

@@ -5,8 +5,7 @@ import BizError from '../error/biz-error';
import { and, desc, eq, lt, sql, inArray } from 'drizzle-orm';
import email from '../entity/email';
import { isDel } from '../const/entity-const';
import { att } from '../entity/att';
import userService from './user-service';
import attService from "./att-service";
const starService = {
@@ -64,6 +63,16 @@ const starService = {
.orderBy(desc(star.emailId))
.limit(size)
.all();
const emailIds = list.map(item => item.emailId);
const attsList = await attService.selectByEmailIds(c, emailIds);
list.forEach(emailRow => {
const atts = attsList.filter(attsRow => attsRow.emailId === emailRow.emailId);
emailRow.attList = atts;
});
return { list };
},
async removeByEmailIds(c, emailIds) {