pushing things I forgot
This commit is contained in:
@@ -64,7 +64,11 @@ router.route("/send-notification").post(async (req, res) => {
|
||||
res.send(false);
|
||||
return;
|
||||
}
|
||||
const message = req.body.message;
|
||||
|
||||
const message = JSON.stringify({
|
||||
message: req.body.message,
|
||||
title: "Vinlotteri!"
|
||||
});
|
||||
let subs = await Subscription.find();
|
||||
for (let i = 0; i < subs.length; i++) {
|
||||
let subscription = subs[i]; //get subscription from your databse here.
|
||||
@@ -80,10 +84,14 @@ schedule.scheduleJob(
|
||||
let subs = await Subscription.find();
|
||||
for (let i = 0; i < subs.length; i++) {
|
||||
let subscription = subs[i]; //get subscription from your databse here.
|
||||
const message = "Husk vinlotteriet, det begynner om 10 minutter!";
|
||||
const message = JSON.stringify({
|
||||
message: "Husk vinlotteriet, det begynner om 10 minutter!",
|
||||
title: "Vinlotteri!"
|
||||
});
|
||||
sendNotification(subscription, message);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = router;
|
||||
module.exports.sendNotification = sendNotification;
|
||||
|
||||
@@ -6,6 +6,9 @@ mongoose.connect("mongodb://localhost:27017/vinlottis", {
|
||||
useNewUrlParser: true
|
||||
});
|
||||
|
||||
const sub = require(path.join(__dirname + "/../api/subscriptions"));
|
||||
|
||||
const Subscription = require(path.join(__dirname + "/../schemas/Subscription"));
|
||||
const Purchase = require(path.join(__dirname + "/../schemas/Purchase"));
|
||||
const Wine = require(path.join(__dirname + "/../schemas/Wine"));
|
||||
const PreLotteryWine = require(path.join(
|
||||
@@ -35,6 +38,16 @@ router.route("/log/wines").post(async (req, res) => {
|
||||
await newWonWine.save();
|
||||
}
|
||||
|
||||
let subs = await Subscription.find();
|
||||
for (let i = 0; i < subs.length; i++) {
|
||||
let subscription = subs[i]; //get subscription from your databse here.
|
||||
const message = JSON.stringify({
|
||||
message: "Dagens vin er lagt til, se den på lottis.vin/dagens!",
|
||||
title: "Ny vin!"
|
||||
});
|
||||
sub.sendNotification(subscription, message);
|
||||
}
|
||||
|
||||
res.send(true);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user