From 9bee0e460bfebe8db76742b80b2d52854392f4de Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Fri, 30 Jan 2026 17:08:17 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BF=AE=E5=A4=8D=E6=97=A7=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E6=B5=81=E6=B0=B4=E7=BA=BF=E6=95=B0=E6=8D=AE=E5=8F=91?= =?UTF-8?q?=E9=80=81=E9=80=9A=E7=9F=A5=E6=A0=87=E9=A2=98=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/pipeline/src/core/executor.ts | 2 + .../modules/basic/service/email-service.ts | 48 +++++++++++-------- .../lecdn/plugins/plugin-update-cert-v2.ts | 2 +- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/packages/core/pipeline/src/core/executor.ts b/packages/core/pipeline/src/core/executor.ts index d7f88b383..cf39ad379 100644 --- a/packages/core/pipeline/src/core/executor.ts +++ b/packages/core/pipeline/src/core/executor.ts @@ -465,6 +465,8 @@ export class Executor { templateData.errors = errors; templateData.pipelineResult = pipelineResult; + templateData.title = subject; + templateData.content = content; for (const notification of this.pipeline.notifications) { if (!notification.when.includes(when)) { diff --git a/packages/ui/certd-server/src/modules/basic/service/email-service.ts b/packages/ui/certd-server/src/modules/basic/service/email-service.ts index 200ec35d6..9d67a5a83 100644 --- a/packages/ui/certd-server/src/modules/basic/service/email-service.ts +++ b/packages/ui/certd-server/src/modules/basic/service/email-service.ts @@ -77,6 +77,13 @@ export class EmailService implements IEmailService { } } let subject = email.subject; + + if (!subject) { + logger.error(new Error('邮件标题不能为空')); + subject = `邮件标题为空,请联系管理员排查`; + } + + if (!subject.includes(`【${sysTitle}】`)) { subject = `【${sysTitle}】${subject}`; } @@ -121,7 +128,7 @@ export class EmailService implements IEmailService { data: { title: '测试邮件,from certd', content: '测试邮件,from certd', - url:"https://certd.handfree.work", + url: "https://certd.handfree.work", }, receivers: [receiver], }); @@ -150,32 +157,33 @@ export class EmailService implements IEmailService { async sendByTemplate(req: EmailSendByTemplateReq) { let content = null - if (isPlus()) { - const emailConf = await this.sysSettingsService.getSetting(SysEmailConf); - const template = emailConf?.templates?.[req.type] - if (template && template.addonId) { + const emailConf = await this.sysSettingsService.getSetting(SysEmailConf); + const template = emailConf?.templates?.[req.type] + if (template && isPlus()) { + if (template.addonId) { const addon: ITemplateProvider = await this.addonGetterService.getAddonById(template.addonId, true, 0) if (addon) { content = await addon.buildContent({ data: req.data }) } } - if (!content) { - //看看有没有通用模版 - if (emailConf?.templates?.common && emailConf?.templates?.common.addonId) { - const addon: ITemplateProvider = await this.addonGetterService.getAddonById(emailConf.templates.common.addonId, true, 0) - if (addon) { - content = await addon.buildContent({ data: req.data }) - } + } + if (!content && isPlus()) { + //看看有没有通用模版 + if (emailConf?.templates?.common && emailConf?.templates?.common.addonId) { + const addon: ITemplateProvider = await this.addonGetterService.getAddonById(emailConf.templates.common.addonId, true, 0) + if (addon) { + content = await addon.buildContent({ data: req.data }) } } - // 没有找到模版,使用默认模版 - if (!content) { - try { - const addon: ITemplateProvider = await this.addonGetterService.getBlank("emailTemplate", req.type) - content = await addon.buildDefaultContent({ data: req.data }) - } catch (e) { - // 对应的通知类型模版可能没有注册或者开发 - } + } + + // 没有找到模版,使用默认模版 + if (!content) { + try { + const addon: ITemplateProvider = await this.addonGetterService.getBlank("emailTemplate", req.type) + content = await addon.buildDefaultContent({ data: req.data }) + } catch (e) { + // 对应的通知类型模版可能没有注册或者开发 } } diff --git a/packages/ui/certd-server/src/plugins/plugin-plus/lecdn/plugins/plugin-update-cert-v2.ts b/packages/ui/certd-server/src/plugins/plugin-plus/lecdn/plugins/plugin-update-cert-v2.ts index d009209d2..f50093172 100644 --- a/packages/ui/certd-server/src/plugins/plugin-plus/lecdn/plugins/plugin-update-cert-v2.ts +++ b/packages/ui/certd-server/src/plugins/plugin-plus/lecdn/plugins/plugin-update-cert-v2.ts @@ -136,7 +136,7 @@ export class LeCDNUpdateCertV2 extends AbstractTaskPlugin { private checkRes(res: any) { if (res.code !== 0 && res.code !== 200) { - throw new Error(res.message); + throw new Error(res.message || JSON.stringify(res)); } }