diff options
| author | Adam Soltys <[email protected]> | 2021-05-15 01:09:10 -0400 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2021-05-15 01:09:10 -0400 |
| commit | 3fc5dee44471633129ea01baeaf61afad695f4b7 (patch) | |
| tree | bb16642b336b030fbfbdf32a9dfc013e62b6ccd1 | |
| parent | 9a56065bbb93a3c7c6dd655b37a2ac825d175f14 (diff) | |
| download | coinos-server-3fc5dee44471633129ea01baeaf61afad695f4b7.tar.gz coinos-server-3fc5dee44471633129ea01baeaf61afad695f4b7.zip | |
build notifications
| -rw-r--r-- | index.js | 34 | ||||
| -rw-r--r-- | routes/funding.js | 7 |
2 files changed, 34 insertions, 7 deletions
@@ -109,13 +109,41 @@ function verifyPostData(req, res, next) { return next(); } -app.post("/build", verifyPostData, (req, res) => { +app.post("/build", (req, res) => { + const mailgun = require("mailgun-js")(config.mailgun); + let data = { + subject: "Build started", + text: `Build started at ${new Date()}`, + from: "[email protected]", + to: "[email protected]" + }; + + mailgun.messages().send(data); + l.info("Build starting"); fs.writeFileSync("build.json", req.body.payload); const { exec } = require("child_process"); exec("bash build.sh", (error, stdout, stderr) => { - if (error !== null) { - console.log(`exec error: ${error}`); + if (error) { + data = { + subject: "Build error", + text: `Build failed at ${new Date()}`, + from: "[email protected]", + to: "[email protected]" + }; + + mailgun.messages().send(data); + l.warn("Build failed"); + } else { + data = { + subject: "Build finished", + text: `Build finished at ${new Date()}`, + from: "[email protected]", + to: "[email protected]" + }; + + mailgun.messages().send(data); + l.info("Build finished"); } }); }); diff --git a/routes/funding.js b/routes/funding.js index b398d341..2335ba3a 100644 --- a/routes/funding.js +++ b/routes/funding.js @@ -34,11 +34,10 @@ app.post( emit(user.username, "user", user); let data = { - ...config.mail, - subject: "KYC Documents", - text: `ID uploaded for ${user.username}`, + subject: "Build started", + text: `Build started at ${new Date()}`, from: "[email protected]", - to: "[email protected]" + to: "[email protected]" }; mailgun.messages().send(data); |
