diff --git a/packages/core/pipeline/src/core/executor.ts b/packages/core/pipeline/src/core/executor.ts index cf29d8d46..e21a33b7c 100644 --- a/packages/core/pipeline/src/core/executor.ts +++ b/packages/core/pipeline/src/core/executor.ts @@ -435,7 +435,7 @@ export class Executor { content, userId: this.pipeline.userId, pipeline: this.pipeline, - result: this.lastRuntime.pipeline.status, + result: this.lastRuntime?.pipeline?.status, pipelineId: this.pipeline.id, historyId: this.runtime.id, errorMessage, diff --git a/packages/core/pipeline/src/notification/api.ts b/packages/core/pipeline/src/notification/api.ts index 161ca1960..fe465e042 100644 --- a/packages/core/pipeline/src/notification/api.ts +++ b/packages/core/pipeline/src/notification/api.ts @@ -121,11 +121,11 @@ export abstract class BaseNotification implements INotification { async onTestRequest() { await this.doSend({ userId: 0, - title: "【Certd】测试通知,标题长度测试、测试、测试", - content: "测试通知", + title: "【Certd】测试通知【*.foo.com】,标题长度测试、测试、测试", + content: "测试通知,*.foo.com", pipeline: { id: 1, - title: "测试流水线", + title: "证书申请成功【测试流水线】", } as any, pipelineId: 1, historyId: 1, diff --git a/packages/ui/certd-server/src/plugins/plugin-notification/telegram/index.ts b/packages/ui/certd-server/src/plugins/plugin-notification/telegram/index.ts index 434ca2eba..8ea01da5e 100644 --- a/packages/ui/certd-server/src/plugins/plugin-notification/telegram/index.ts +++ b/packages/ui/certd-server/src/plugins/plugin-notification/telegram/index.ts @@ -58,13 +58,16 @@ export class TelegramNotification extends BaseNotification { }) skipSslVerify: boolean; + replaceText(text: string) { + return text.replaceAll('.', '\\.').replaceAll('*', '\\*'); + } async send(body: NotificationBody) { if (!this.botToken || !this.chatId) { throw new Error('Bot Token 和聊天ID不能为空'); } // 构建消息内容 - const messageContent = `*${body.title}*\n\n${body.content}\n\n[查看详情](${body.url})`; + const messageContent = `${this.replaceText(body.title)}\n\n${this.replaceText(body.content)}\n\n[查看详情](${body.url})`; // Telegram API URL const url = `https://api.telegram.org/bot${this.botToken}/sendMessage`;