Fix automatic choser issue
This commit is contained in:
@@ -41,6 +41,7 @@ async function sendMessageTooLate(winnerObject) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function sendMessageToUser(phoneNumber, message) {
|
async function sendMessageToUser(phoneNumber, message) {
|
||||||
|
try {
|
||||||
request.post(
|
request.post(
|
||||||
{
|
{
|
||||||
url: `https://gatewayapi.com/rest/mtsms?token=${config.gatewayToken}`,
|
url: `https://gatewayapi.com/rest/mtsms?token=${config.gatewayToken}`,
|
||||||
@@ -53,8 +54,14 @@ async function sendMessageToUser(phoneNumber, message) {
|
|||||||
},
|
},
|
||||||
function(err, r, body) {
|
function(err, r, body) {
|
||||||
console.log(err ? err : body);
|
console.log(err ? err : body);
|
||||||
|
if(err) {
|
||||||
|
console.log(phoneNumber, message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
} catch(e) {
|
||||||
|
console.log(phoneNumber, message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sendUpdate(winners) {
|
async function sendUpdate(winners) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
const Highscore = require(path.join(__dirname + "/../schemas/Highscore"));
|
const Highscore = require(path.join(__dirname + "/../schemas/Highscore"));
|
||||||
|
|
||||||
async function findSavePerson(foundWinner, wonWine) {
|
async function findSavePerson(foundWinner, wonWine, date) {
|
||||||
let person = await Highscore.findOne({
|
let person = await Highscore.findOne({
|
||||||
name: foundWinner.name
|
name: foundWinner.name
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ router.route("/log").post(mustBeAuthenticated, async (req, res) => {
|
|||||||
let wonWine = await _wineFunctions.findSaveWine(currentWinner);
|
let wonWine = await _wineFunctions.findSaveWine(currentWinner);
|
||||||
winesThisDate.push(wonWine);
|
winesThisDate.push(wonWine);
|
||||||
|
|
||||||
await _personFunctions.findSavePerson(currentWinner, wonWine);
|
await _personFunctions.findSavePerson(currentWinner, wonWine, date);
|
||||||
}
|
}
|
||||||
|
|
||||||
let purchase = new Purchase({
|
let purchase = new Purchase({
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ router.route("/:id").post(async (req, res) => {
|
|||||||
|
|
||||||
let wonWine = await _wineFunctions.findSaveWine(prelotteryWine);
|
let wonWine = await _wineFunctions.findSaveWine(prelotteryWine);
|
||||||
await prelotteryWine.delete();
|
await prelotteryWine.delete();
|
||||||
await _personFunctions.findSavePerson(foundWinner, wonWine);
|
await _personFunctions.findSavePerson(foundWinner, wonWine, date);
|
||||||
|
|
||||||
await foundWinner.delete();
|
await foundWinner.delete();
|
||||||
|
|
||||||
@@ -111,10 +111,11 @@ async function chooseForUser(winner, prelotteryWine) {
|
|||||||
let date = new Date();
|
let date = new Date();
|
||||||
date.setHours(5, 0, 0, 0);
|
date.setHours(5, 0, 0, 0);
|
||||||
let wonWine = await _wineFunctions.findSaveWine(prelotteryWine);
|
let wonWine = await _wineFunctions.findSaveWine(prelotteryWine);
|
||||||
await _personFunctions.findSavePerson(winner, wonWine);
|
await _personFunctions.findSavePerson(winner, wonWine, date);
|
||||||
|
|
||||||
await prelotteryWine.delete();
|
await prelotteryWine.delete();
|
||||||
Message.sendWonWineMessage(winner, prelotteryWine);
|
await Message.sendWonWineMessage(winner, prelotteryWine);
|
||||||
|
await winner.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
function startTimeout(id) {
|
function startTimeout(id) {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ try {
|
|||||||
message: "INSERT MESSAGE",
|
message: "INSERT MESSAGE",
|
||||||
date: 5,
|
date: 5,
|
||||||
hours: 15,
|
hours: 15,
|
||||||
apiUrl: "https://lottis.vin",
|
apiUrl: "http://localhost:30030",
|
||||||
gatewayToken: undefined
|
gatewayToken: undefined
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user