mirror of
https://github.com/schroinerxy/cloud-mail.git
synced 2026-06-21 19:35:50 +08:00
修复可能导致收件失败问题回退优化自动刷新
This commit is contained in:
@@ -27,10 +27,19 @@ const dbInit = {
|
||||
await this.v2_6DB(c);
|
||||
await this.v2_7DB(c);
|
||||
await this.v2_8DB(c);
|
||||
await this.v2_9DB(c);
|
||||
await settingService.refresh(c);
|
||||
return c.text('success');
|
||||
},
|
||||
|
||||
async v2_9DB(c) {
|
||||
try {
|
||||
await c.env.db.prepare(`UPDATE setting SET auto_refresh = 5 WHERE auto_refresh = 1;`).run();
|
||||
} catch (e) {
|
||||
console.warn(`跳过字段:${e.message}`);
|
||||
}
|
||||
},
|
||||
|
||||
async v2_8DB(c) {
|
||||
try {
|
||||
await c.env.db.batch([
|
||||
@@ -44,8 +53,7 @@ const dbInit = {
|
||||
async v2_7DB(c) {
|
||||
try {
|
||||
await c.env.db.batch([
|
||||
c.env.db.prepare(`ALTER TABLE setting RENAME COLUMN auto_refresh_time TO auto_refresh;`),
|
||||
c.env.db.prepare(`UPDATE setting SET auto_refresh = 1 WHERE auto_refresh != 0;`)
|
||||
c.env.db.prepare(`ALTER TABLE setting RENAME COLUMN auto_refresh_time TO auto_refresh;`)
|
||||
]);
|
||||
} catch (e) {
|
||||
console.warn(`跳过字段:${e.message}`);
|
||||
|
||||
@@ -446,30 +446,22 @@ const emailService = {
|
||||
allReceive = accountRow.allReceive;
|
||||
}
|
||||
|
||||
let count = 0
|
||||
let list = []
|
||||
|
||||
while ((count < 6) && list.length === 0) {
|
||||
list = await orm(c).select({...email}).from(email)
|
||||
.leftJoin(
|
||||
account,
|
||||
eq(account.accountId, email.accountId)
|
||||
)
|
||||
.where(
|
||||
and(
|
||||
gt(email.emailId, emailId),
|
||||
eq(email.userId, userId),
|
||||
eq(email.isDel, isDel.NORMAL),
|
||||
eq(account.isDel, isDel.NORMAL),
|
||||
allReceive ? eq(1,1) : eq(email.accountId, accountId),
|
||||
eq(email.type, emailConst.type.RECEIVE)
|
||||
))
|
||||
.orderBy(desc(email.emailId))
|
||||
.limit(20);
|
||||
|
||||
await sleep(5000);
|
||||
count++
|
||||
}
|
||||
let list = await orm(c).select({...email}).from(email)
|
||||
.leftJoin(
|
||||
account,
|
||||
eq(account.accountId, email.accountId)
|
||||
)
|
||||
.where(
|
||||
and(
|
||||
gt(email.emailId, emailId),
|
||||
eq(email.userId, userId),
|
||||
eq(email.isDel, isDel.NORMAL),
|
||||
eq(account.isDel, isDel.NORMAL),
|
||||
allReceive ? eq(1,1) : eq(email.accountId, accountId),
|
||||
eq(email.type, emailConst.type.RECEIVE)
|
||||
))
|
||||
.orderBy(desc(email.emailId))
|
||||
.limit(20);
|
||||
|
||||
await this.emailAddAtt(c, list);
|
||||
|
||||
@@ -630,24 +622,16 @@ const emailService = {
|
||||
|
||||
const { emailId } = params;
|
||||
|
||||
let count = 0
|
||||
let list = []
|
||||
|
||||
while ((count < 6) && list.length === 0) {
|
||||
list = await orm(c).select({...email, userEmail: user.email}).from(email)
|
||||
.leftJoin(user, eq(email.userId, user.userId))
|
||||
.where(
|
||||
and(
|
||||
gt(email.emailId, emailId),
|
||||
eq(email.type, emailConst.type.RECEIVE),
|
||||
ne(email.status, emailConst.status.SAVING)
|
||||
))
|
||||
.orderBy(desc(email.emailId))
|
||||
.limit(20);
|
||||
|
||||
await sleep(5000);
|
||||
count++
|
||||
}
|
||||
let list = await orm(c).select({...email, userEmail: user.email}).from(email)
|
||||
.leftJoin(user, eq(email.userId, user.userId))
|
||||
.where(
|
||||
and(
|
||||
gt(email.emailId, emailId),
|
||||
eq(email.type, emailConst.type.RECEIVE),
|
||||
ne(email.status, emailConst.status.SAVING)
|
||||
))
|
||||
.orderBy(desc(email.emailId))
|
||||
.limit(20);
|
||||
|
||||
await this.emailAddAtt(c, list);
|
||||
|
||||
@@ -660,10 +644,10 @@ const emailService = {
|
||||
|
||||
if (emailIds.length > 0) {
|
||||
|
||||
const attsList = await attService.selectByEmailIds(c, emailIds);
|
||||
const attList = await attService.selectByEmailIds(c, emailIds);
|
||||
|
||||
list.forEach(emailRow => {
|
||||
const atts = attsList.filter(attsRow => attsRow.emailId === emailRow.emailId);
|
||||
const atts = attList.filter(attRow => attRow.emailId === emailRow.emailId);
|
||||
emailRow.attList = atts;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user