update sms over speed condition, user got sms if vehicle id is same with role

This commit is contained in:
wayanrivan
2026-07-08 13:24:04 +07:00
parent 07ecfb2f93
commit 5d5fb7a980

View File

@ -338,7 +338,11 @@ async function commitMessage(now, logDevice) {
// check speed limit, if speed > vhc.speed_limit, send sms
if (Array.isArray(vhc) && vhc.length > 0 && vhc[0].speed_limit > 0 && logDevice.speed > vhc[0].speed_limit) {
const users = await db.query(`SELECT phone FROM t_users WHERE status_sms = 1`, [])
// const users = await db.query(`SELECT phone FROM t_users WHERE status_sms = 1`, [])
const users = await db.query(
`SELECT phone FROM t_users WHERE status_sms = 1 AND FIND_IN_SET(?, vhc) > 0`,
[vhc[0].id]
)
if (!users?.length) return
const nopol = (vhc[0].nopol1 ?? "") + (vhc[0].nopol2 ?? "") + (vhc[0].nopol3 ?? "")