perf: 修复旧版本流水线数据发送通知标题为空的bug

This commit is contained in:
xiaojunnuo
2026-01-30 17:08:17 +08:00
parent 933aaeaf25
commit 9bee0e460b
3 changed files with 31 additions and 21 deletions
@@ -465,6 +465,8 @@ export class Executor {
templateData.errors = errors; templateData.errors = errors;
templateData.pipelineResult = pipelineResult; templateData.pipelineResult = pipelineResult;
templateData.title = subject;
templateData.content = content;
for (const notification of this.pipeline.notifications) { for (const notification of this.pipeline.notifications) {
if (!notification.when.includes(when)) { if (!notification.when.includes(when)) {
@@ -77,6 +77,13 @@ export class EmailService implements IEmailService {
} }
} }
let subject = email.subject; let subject = email.subject;
if (!subject) {
logger.error(new Error('邮件标题不能为空'));
subject = `邮件标题为空,请联系管理员排查`;
}
if (!subject.includes(`${sysTitle}`)) { if (!subject.includes(`${sysTitle}`)) {
subject = `${sysTitle}${subject}`; subject = `${sysTitle}${subject}`;
} }
@@ -121,7 +128,7 @@ export class EmailService implements IEmailService {
data: { data: {
title: '测试邮件,from certd', title: '测试邮件,from certd',
content: '测试邮件,from certd', content: '测试邮件,from certd',
url:"https://certd.handfree.work", url: "https://certd.handfree.work",
}, },
receivers: [receiver], receivers: [receiver],
}); });
@@ -150,16 +157,17 @@ export class EmailService implements IEmailService {
async sendByTemplate(req: EmailSendByTemplateReq) { async sendByTemplate(req: EmailSendByTemplateReq) {
let content = null let content = null
if (isPlus()) {
const emailConf = await this.sysSettingsService.getSetting<SysEmailConf>(SysEmailConf); const emailConf = await this.sysSettingsService.getSetting<SysEmailConf>(SysEmailConf);
const template = emailConf?.templates?.[req.type] const template = emailConf?.templates?.[req.type]
if (template && template.addonId) { if (template && isPlus()) {
if (template.addonId) {
const addon: ITemplateProvider<EmailContent> = await this.addonGetterService.getAddonById(template.addonId, true, 0) const addon: ITemplateProvider<EmailContent> = await this.addonGetterService.getAddonById(template.addonId, true, 0)
if (addon) { if (addon) {
content = await addon.buildContent({ data: req.data }) content = await addon.buildContent({ data: req.data })
} }
} }
if (!content) { }
if (!content && isPlus()) {
//看看有没有通用模版 //看看有没有通用模版
if (emailConf?.templates?.common && emailConf?.templates?.common.addonId) { if (emailConf?.templates?.common && emailConf?.templates?.common.addonId) {
const addon: ITemplateProvider<EmailContent> = await this.addonGetterService.getAddonById(emailConf.templates.common.addonId, true, 0) const addon: ITemplateProvider<EmailContent> = await this.addonGetterService.getAddonById(emailConf.templates.common.addonId, true, 0)
@@ -168,6 +176,7 @@ export class EmailService implements IEmailService {
} }
} }
} }
// 没有找到模版,使用默认模版 // 没有找到模版,使用默认模版
if (!content) { if (!content) {
try { try {
@@ -177,7 +186,6 @@ export class EmailService implements IEmailService {
// 对应的通知类型模版可能没有注册或者开发 // 对应的通知类型模版可能没有注册或者开发
} }
} }
}
if (!content) { if (!content) {
const addon: ITemplateProvider<EmailContent> = await this.addonGetterService.getBlank("emailTemplate", "common") const addon: ITemplateProvider<EmailContent> = await this.addonGetterService.getBlank("emailTemplate", "common")
@@ -136,7 +136,7 @@ export class LeCDNUpdateCertV2 extends AbstractTaskPlugin {
private checkRes(res: any) { private checkRes(res: any) {
if (res.code !== 0 && res.code !== 200) { if (res.code !== 0 && res.code !== 200) {
throw new Error(res.message); throw new Error(res.message || JSON.stringify(res));
} }
} }