fix: 修复站点监控通知通过webhook发送失败的bug

This commit is contained in:
xiaojunnuo
2025-03-17 18:20:15 +08:00
parent 729b19c8da
commit 9be1ecc8aa
4 changed files with 12 additions and 13 deletions
@@ -78,7 +78,7 @@ export class WebhookNotification extends BaseNotification {
col: {
span: 24,
},
helper: `根据实际的webhook接口,构建一个json对象作为参数支持变量:{title}、{content}、{url},变量用{}包裹字符串需要双引号\n如果是get方式,将作为query参数拼接到url上`,
helper: `根据对应的webhook接口文档,构建一个json对象作为参数(默认值只是一个示例,一般不是正确的参数)\n支持变量:{title}、{content}、{url},变量用{}包裹\n字符串需要双引号,使用\\n换行\n如果是get方式,将作为query参数拼接到url上`,
required: true,
})
template = '';
@@ -98,8 +98,10 @@ export class WebhookNotification extends BaseNotification {
let bodyStr = target;
const keys = Object.keys(body);
for (const key of keys) {
const value = urlEncode ? encodeURIComponent(body[key]) : body[key];
let value = urlEncode ? encodeURIComponent(body[key]) : body[key];
value = value.replaceAll(`\n`, "\\n");
bodyStr = bodyStr.replaceAll(`{${key}}`, value);
}
return bodyStr;
}