mirror of
https://github.com/certd/certd.git
synced 2026-04-24 12:27:25 +08:00
perf: 修复旧版本流水线数据发送通知标题为空的bug
This commit is contained in:
@@ -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,32 +157,33 @@ 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 && isPlus()) {
|
||||||
if (template && template.addonId) {
|
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) {
|
//看看有没有通用模版
|
||||||
const addon: ITemplateProvider<EmailContent> = await this.addonGetterService.getAddonById(emailConf.templates.common.addonId, true, 0)
|
if (emailConf?.templates?.common && emailConf?.templates?.common.addonId) {
|
||||||
if (addon) {
|
const addon: ITemplateProvider<EmailContent> = await this.addonGetterService.getAddonById(emailConf.templates.common.addonId, true, 0)
|
||||||
content = await addon.buildContent({ data: req.data })
|
if (addon) {
|
||||||
}
|
content = await addon.buildContent({ data: req.data })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 没有找到模版,使用默认模版
|
}
|
||||||
if (!content) {
|
|
||||||
try {
|
// 没有找到模版,使用默认模版
|
||||||
const addon: ITemplateProvider<EmailContent> = await this.addonGetterService.getBlank("emailTemplate", req.type)
|
if (!content) {
|
||||||
content = await addon.buildDefaultContent({ data: req.data })
|
try {
|
||||||
} catch (e) {
|
const addon: ITemplateProvider<EmailContent> = await this.addonGetterService.getBlank("emailTemplate", req.type)
|
||||||
// 对应的通知类型模版可能没有注册或者开发
|
content = await addon.buildDefaultContent({ data: req.data })
|
||||||
}
|
} catch (e) {
|
||||||
|
// 对应的通知类型模版可能没有注册或者开发
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user