This commit is contained in:
pringgosutono
2026-05-06 14:02:43 +07:00
parent c898b1808a
commit 71d02fd489

View File

@ -338,20 +338,28 @@ async function commitMessage(now, logDevice) {
const users = await db.query(queryUsers, [])
if (users && users.length > 0) {
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) {
if (user.phone) {
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
await db.query(`insert into sms_notif
set
to_no = ?,`,
`message = ?`,
[user.phone, msg])
await db.query(
`insert into sms_notif set to_no = ?, message = ?`,
[user.phone, rawMsg],
)
} catch (err) {
console.error("Error sending SMS : ", JSON.stringify(err))
console.error(
"Error sending SMS : ",
err.response ? JSON.stringify(err.response.data) : err.message,
)
}
}
}