新增无人收件和支持一些字符邮箱
This commit is contained in:
@@ -25,7 +25,7 @@ export const permConst = {
|
||||
export const emailConst = {
|
||||
type: {
|
||||
SEND: 1,
|
||||
RECEIVE: 0,
|
||||
RECEIVE: 0
|
||||
},
|
||||
status: {
|
||||
RECEIVE: 0,
|
||||
@@ -34,7 +34,8 @@ export const emailConst = {
|
||||
BOUNCED: 3,
|
||||
COMPLAINED: 4,
|
||||
DELAYED: 5,
|
||||
SAVING: 6
|
||||
SAVING: 6,
|
||||
NOONE: 7
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,6 @@ export async function email(message, env, ctx) {
|
||||
|
||||
const email = await PostalMime.parse(content);
|
||||
|
||||
console.warn(email)
|
||||
|
||||
const params = {
|
||||
sendEmail: email.from.address,
|
||||
name: email.from.name,
|
||||
@@ -42,8 +40,8 @@ export async function email(message, env, ctx) {
|
||||
inReplyTo: email.inReplyTo,
|
||||
relation: email.references,
|
||||
messageId: email.messageId,
|
||||
userId: account.userId,
|
||||
accountId: account.accountId,
|
||||
userId: account ? account.userId : 0,
|
||||
accountId: account ? account.accountId : 0,
|
||||
isDel: isDel.DELETE,
|
||||
status: emailConst.status.SAVING
|
||||
};
|
||||
@@ -74,7 +72,7 @@ export async function email(message, env, ctx) {
|
||||
await attService.addAtt({ env }, attachments);
|
||||
}
|
||||
|
||||
await emailService.completeReceive({ env }, emailRow.emailId);
|
||||
await emailService.completeReceive({ env },account ? emailConst.status.RECEIVE : emailConst.status.NOONE, emailRow.emailId);
|
||||
|
||||
} catch (e) {
|
||||
console.error('邮件接收异常: ', e);
|
||||
|
||||
@@ -505,6 +505,10 @@ const emailService = {
|
||||
conditions.push(eq(email.isDel, isDel.DELETE));
|
||||
}
|
||||
|
||||
if (type === 'noone') {
|
||||
conditions.push(eq(email.status, emailConst.status.NOONE));
|
||||
}
|
||||
|
||||
if (userEmail) {
|
||||
conditions.push(like(user.email, `${userEmail}%`));
|
||||
}
|
||||
@@ -569,10 +573,10 @@ const emailService = {
|
||||
await orm(c).update(email).set({ isDel: isDel.NORMAL }).where(eq(email.userId, userId)).run();
|
||||
},
|
||||
|
||||
async completeReceive(c, emailId) {
|
||||
async completeReceive(c, status, emailId) {
|
||||
await orm(c).update(email).set({
|
||||
isDel: isDel.NORMAL,
|
||||
status: emailConst.status.RECEIVE
|
||||
status: status
|
||||
}).where(eq(email.emailId, emailId)).run();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const verifyUtils = {
|
||||
isEmail(str) {
|
||||
return /^[a-zA-Z0-9]+@([a-zA-Z0-9-]+\.)+[a-zA-Z0-9-]+$/.test(str);
|
||||
return /^[a-zA-Z0-9!#$%&'*+/=?^_`{|}~.-]+@([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/.test(str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user