update 2
This commit is contained in:
@ -338,20 +338,28 @@ async function commitMessage(now, logDevice) {
|
|||||||
const users = await db.query(queryUsers, [])
|
const users = await db.query(queryUsers, [])
|
||||||
if (users && users.length > 0) {
|
if (users && users.length > 0) {
|
||||||
const nopol = (vhc[0].nopol1 || "") + (vhc[0].nopol2 || "") + (vhc[0].nopol3 || "")
|
const nopol = (vhc[0].nopol1 || "") + (vhc[0].nopol2 || "") + (vhc[0].nopol3 || "")
|
||||||
const msg = encodeURIComponent(`${nopol} | OVERSPEED | ${logDevice.crt_d_format}| ${logDevice.speed} km/h `)
|
const rawMsg = `${nopol} | OVERSPEED | ${logDevice.crt_d_format} | ${logDevice.speed} km/h`
|
||||||
for (let user of users) {
|
for (let user of users) {
|
||||||
if (user.phone) {
|
if (user.phone) {
|
||||||
try {
|
try {
|
||||||
await axios.get(`http://192.168.40.2:8181/mobicents/sendSms?to=670${user.phone}&msg=${msg}&sender=Movana`)
|
await axios.get(`http://192.168.40.2:8181/mobicents/sendSms`, {
|
||||||
|
params: {
|
||||||
|
to: `670${user.phone}`,
|
||||||
|
msg: rawMsg,
|
||||||
|
sender: "Movana",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
// insert logs
|
// insert logs
|
||||||
await db.query(`insert into sms_notif
|
await db.query(
|
||||||
set
|
`insert into sms_notif set to_no = ?, message = ?`,
|
||||||
to_no = ?,`,
|
[user.phone, rawMsg],
|
||||||
`message = ?`,
|
)
|
||||||
[user.phone, msg])
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Error sending SMS : ", JSON.stringify(err))
|
console.error(
|
||||||
|
"Error sending SMS : ",
|
||||||
|
err.response ? JSON.stringify(err.response.data) : err.message,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user