From 536ce89c7db5dd3dbbffd606b6be3d7649ecc130 Mon Sep 17 00:00:00 2001 From: TheCoreDev Date: Mon, 27 Nov 2023 13:05:47 +0100 Subject: [PATCH] =?UTF-8?q?Rajout=20d'une=20notification=20ntfy=20=20?= =?UTF-8?q?=C3=A0=20chaque=20r=C3=A9ponse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 2 +- .gitignore | 1 + wishlist.js | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.env b/.env index 532cd11..9ab3b4a 100644 --- a/.env +++ b/.env @@ -1,5 +1,5 @@ DATABASE = wishlist -DATABASE_HOST = 127.0.0.1 +DATABASE_HOST = db.thecoredev.fr DATABASE_PORT = 3306 DATABASE_USER = wishlist DATABASE_PASSWORD = 7/yvv9JA[RomOkLe \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c49bd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env diff --git a/wishlist.js b/wishlist.js index 51ab21f..141e992 100644 --- a/wishlist.js +++ b/wishlist.js @@ -130,12 +130,19 @@ app.post("/confirm-reservation", (req, res) => { app.get("/presence-anniversaire", (req, res) => { let enfant = req.query.e; let present = req.query.p; + let messageNotif = enfant + (present == 'true' ? "" : "ne") + " sera" + (present == 'true' ? "" : "pas") + " là le 17 décembre"; db.query("DELETE FROM anniversaire WHERE enfant = ?", [enfant], function (err, result) { if (err) throw err; db.query("INSERT INTO anniversaire (enfant, present) VALUES (?, ?)", [enfant, (present == 'true' ? 1 : 0)], function (err, result) { if (err) throw err; + + fetch('https://ntfy.sh/presence-anniversaire-louisa', { + method: "POST", + body: messageNotif +}) + res.render('votre-vote', { "enfant": enfant, "present": (present == 'true' ? 1 : 0) }); }); });