diff --git a/package.json b/package.json index 34ed697..bc44050 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ }, "author": "kubbo", "dependencies": { + "axios": "^1.2.1", "dayjs": "^1.11.0", "express": "^4.17.3", "fs-extra": "^10.0.1", diff --git a/src/rest/custom/webhook.js b/src/rest/custom/webhook.js new file mode 100644 index 0000000..f17f2bc --- /dev/null +++ b/src/rest/custom/webhook.js @@ -0,0 +1,26 @@ +const dbUtils = require("../../utils/dbUitls"); +const axios = require("axios"); +module.exports = { + action: "/node/custom/webhook", + method: "post", + execute: (request, response) => { + let id = request.query?.id + dbUtils.detail({table: 'node_custom_config', id}).then(info => { + if (info?.id) { + axios.post("https://qyapi.weixin.qq.com/cgi-bin/webhook/send", { + msgtype: "markdown", + markdown: { + content: `> 发布系统:${info.name} + > 发布版本:${info.version} + > 打包完成时间:${info.download}` + } + }, {params: {key: "a5971027-2dd3-4c23-a4e4-c99a962d25a7",}}).then(res => { + response.send({code: 0, msg: res.data}) + }) + } else response.send({code: 1, err: "无法找到项目信息"}) + }).catch(err => { + console.log(err) + response.send({code: 1, err: err.sqlMessage}) + }) + } +}