Rajout d'une notification ntfy à chaque réponse

This commit is contained in:
2023-11-27 13:05:47 +01:00
parent f5262fc139
commit 536ce89c7d
3 changed files with 9 additions and 1 deletions

2
.env
View File

@@ -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

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.env

View File

@@ -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) });
});
});