feat: add category order rules and read-only sent mail history
This commit is contained in:
1 parent
388805a8a6
commit
efa982a8a1
41 files changed
+1828
-28
No files matched your search
@@ -25,7 +25,7 @@ class NotificationService{
|
||||
if(this.stopped)break;
|
||||
const channel=this.mail.store.channelSecret(config.channelId),snapshot={channelId:channel.id,industry:items[0].industry,sourceIds:items.map(i=>i.sourceId),subject:items.length===1?items[0].subject:items[0].industry+'业务通知',text:items.map(i=>i.brief).join('\n\n'),to:[...group.to],cc:[...group.cc],slot:new Date(due).toISOString()};
|
||||
const batch=this.store.prepare(items,snapshot);let transport,sending=false;
|
||||
try{transport=this.mail.smtpFactory(channel.smtp);await transport.verify();this.mail.store.guard(channel.id,channel.version);this.store.beginSending(batch);sending=true;
|
||||
try{if(channel.readOnly)throw Error('只读邮箱不能发送邮件。');transport=this.mail.smtpFactory(channel.smtp);await transport.verify();this.mail.store.guard(channel.id,channel.version);this.store.beginSending(batch);sending=true;
|
||||
const result=await transport.sendMail({from:{address:channel.email,name:channel.name},to:snapshot.to,cc:snapshot.cc,subject:snapshot.subject,text:snapshot.text,attachments:[],messageId:`<${batch}@${channel.email.split('@')[1]}>`,disableFileAccess:true,disableUrlAccess:true});
|
||||
const accepted=new Set((result.accepted||[]).map(a=>String(a.address||a).toLowerCase()));if(result.rejected?.length||[...snapshot.to,...snapshot.cc].some(a=>!accepted.has(a.toLowerCase()))){this.store.mark(batch,'unknown','部分收件人未被邮件服务器接受,请核实后处理。');}else this.store.mark(batch,'sent');
|
||||
}catch{this.store.mark(batch,sending?'unknown':'failed',sending?'发信结果待核实,请查询邮件服务器记录。':'SMTP 连接检查失败,请查看通知队列的重试状态。');}finally{transport?.close?.();}
|
||||
|
||||
Reference in new issue
Block a user