aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--index.js34
-rw-r--r--routes/funding.js7
2 files changed, 34 insertions, 7 deletions
diff --git a/index.js b/index.js
index 871e7530..d7dca11a 100644
--- a/index.js
+++ b/index.js
@@ -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()}`,
+ };
+
+ 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()}`,
+ };
+
+ mailgun.messages().send(data);
+ l.warn("Build failed");
+ } else {
+ data = {
+ subject: "Build finished",
+ text: `Build finished at ${new Date()}`,
+ };
+
+ 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()}`,
};
mailgun.messages().send(data);