From 1c56239fc8fefa680d77cdfd98bd5bafd3ed8d49 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Jul 2026 11:37:47 +0700 Subject: [PATCH 1/4] fix: router reminder --- routes/notifikasi-wa.route.js | 100 +++++++++++++++++----------------- 1 file changed, 51 insertions(+), 49 deletions(-) diff --git a/routes/notifikasi-wa.route.js b/routes/notifikasi-wa.route.js index adce879..940e37f 100644 --- a/routes/notifikasi-wa.route.js +++ b/routes/notifikasi-wa.route.js @@ -1,5 +1,8 @@ const express = require('express'); const router = express.Router(); + +const verifyToken = require("../middleware/verifyToken"); +const verifyAccess = require("../middleware/verifyAccess"); const NotifikasiWaService = require('../services/notifikasi-wa.service'); router.post('/restart-wa', async (req, res) => { @@ -11,18 +14,18 @@ router.post('/restart-wa', async (req, res) => { } }); -router.post('/reminder-monthly/:id', async (req, res) => { +router.post('/reminder-monthly/:id',verifyToken, verifyAccess, async (req, res) => { try { const { id } = req.params; - const {reminder_at_monthly, period} = req.body - const result = await NotifikasiWaService.onMonthlyReminder(id, reminder_at_monthly, period); + const {reminder_at_monthly} = req.body + const result = await NotifikasiWaService.onMonthlyReminder(id, reminder_at_monthly); return res.status(200).json(result); } catch (error) { return res.status(500).json(error); } }); -router.post('/reminder-custom/:id', async (req, res) => { +router.post('/reminder-custom/:id',verifyToken, verifyAccess, async (req, res) => { try { const { id } = req.params; const {start_date, end_date} = req.body; @@ -33,52 +36,51 @@ router.post('/reminder-custom/:id', async (req, res) => { } }); -router.get('/cron/jobs', async (req, res) => { - try { - const activeJobs = NotifikasiWaService.getActiveCronJobs(); - return res.status(200).json({ - success: true, - total: activeJobs.length, - jobs: activeJobs - }); - } catch (error) { - return res.status(500).json({ - success: false, - message: error.message - }); - } -}); +// router.get('/cron/jobs', async (req, res) => { +// try { +// const activeJobs = NotifikasiWaService.getActiveCronJobs(); +// return res.status(200).json({ +// success: true, +// total: activeJobs.length, +// jobs: activeJobs +// }); +// } catch (error) { +// return res.status(500).json({ +// success: false, +// message: error.message +// }); +// } +// }); -router.delete('/cron/jobs/:deviceId', async (req, res) => { - try { - const { deviceId } = req.params; - NotifikasiWaService.stopCronJob(deviceId); - return res.status(200).json({ - success: true, - message: `Cron job untuk device ${deviceId} dihentikan` - }); - } catch (error) { - return res.status(500).json({ - success: false, - message: error.message - }); - } -}); +// router.delete('/cron/jobs/:deviceId', async (req, res) => { +// try { +// const { deviceId } = req.params; +// NotifikasiWaService.stopCronJob(deviceId); +// return res.status(200).json({ +// success: true, +// message: `Cron job untuk device ${deviceId} dihentikan` +// }); +// } catch (error) { +// return res.status(500).json({ +// success: false, +// message: error.message +// }); +// } +// }); -// Endpoint untuk menghentikan semua cron job -router.delete('/cron/jobs', async (req, res) => { - try { - NotifikasiWaService.stopAllCronJobs(); - return res.status(200).json({ - success: true, - message: 'Semua cron job dihentikan' - }); - } catch (error) { - return res.status(500).json({ - success: false, - message: error.message - }); - } -}); +// router.delete('/cron/jobs', async (req, res) => { +// try { +// NotifikasiWaService.stopAllCronJobs(); +// return res.status(200).json({ +// success: true, +// message: 'Semua cron job dihentikan' +// }); +// } catch (error) { +// return res.status(500).json({ +// success: false, +// message: error.message +// }); +// } +// }); module.exports = router; \ No newline at end of file -- 2.49.1 From a52efeceb56a0ba8d8a97d860845bd40eff16e99 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Jul 2026 11:47:11 +0700 Subject: [PATCH 2/4] fix: reminder monthly in db device --- db/device.db.js | 5 ++--- services/notifikasi-wa.service.js | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/db/device.db.js b/db/device.db.js index 3ea1a12..d0dfd8b 100644 --- a/db/device.db.js +++ b/db/device.db.js @@ -155,15 +155,14 @@ const getDeviceReminderMonthlyDb = async (id) => { return result.recordset; }; -const updateDeviceReminderMonthlyDb = async (deviceId, reminderMonthly, period) => { +const updateDeviceReminderMonthlyDb = async (deviceId, reminderMonthly) => { const queryText = ` UPDATE m_device SET reminder_at_monthly = $1, - period = $2 updated_at = CURRENT_TIMESTAMP WHERE device_id = $2 AND deleted_at IS NULL `; - await pool.query(queryText, [reminderMonthly, deviceId, period]); + await pool.query(queryText, [reminderMonthly, deviceId]); return getDeviceByIdDb(deviceId); }; diff --git a/services/notifikasi-wa.service.js b/services/notifikasi-wa.service.js index 276e0b9..d619488 100644 --- a/services/notifikasi-wa.service.js +++ b/services/notifikasi-wa.service.js @@ -614,7 +614,7 @@ class NotifikasiWaService { } - async onMonthlyReminder(deviceId, reminderMonthly, period) { + async onMonthlyReminder(deviceId, reminderMonthly) { try { const paramDb = { @@ -1179,7 +1179,7 @@ class NotifikasiWaService { `Diberitahukan bahwa terdapat sparepart pada device "${deviceName}" ` + `yang telah memasuki jadwal perawatan.\n\n` + `Silakan segera lakukan pengecekan dan perawatan untuk memastikan kinerja tetap optimal.\n\n` + - `Detail Periode Perawatan:\n` + + `Detaile Perawatan:\n` + `Start Date: ${startDateObj.format('DD-MM-YYYY HH:mm')}\n` + `End Date: ${endDateObj.format('DD-MM-YYYY HH:mm')}\n` -- 2.49.1 From b4fe71ccc68dae26c6e1062c9c6f924604c60cc2 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Jul 2026 11:48:32 +0700 Subject: [PATCH 3/4] fix: body message whatsapp in reminder custom --- services/notifikasi-wa.service.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/notifikasi-wa.service.js b/services/notifikasi-wa.service.js index d619488..3e90618 100644 --- a/services/notifikasi-wa.service.js +++ b/services/notifikasi-wa.service.js @@ -1179,7 +1179,7 @@ class NotifikasiWaService { `Diberitahukan bahwa terdapat sparepart pada device "${deviceName}" ` + `yang telah memasuki jadwal perawatan.\n\n` + `Silakan segera lakukan pengecekan dan perawatan untuk memastikan kinerja tetap optimal.\n\n` + - `Detaile Perawatan:\n` + + `Detail Periode Perawatan:\n` + `Start Date: ${startDateObj.format('DD-MM-YYYY HH:mm')}\n` + `End Date: ${endDateObj.format('DD-MM-YYYY HH:mm')}\n` -- 2.49.1 From 13ce1705faa178dc7d64247bbba700e29f802955 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Jul 2026 12:56:08 +0700 Subject: [PATCH 4/4] fix: reminder route --- routes/notifikasi-wa.route.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/routes/notifikasi-wa.route.js b/routes/notifikasi-wa.route.js index 940e37f..673c30e 100644 --- a/routes/notifikasi-wa.route.js +++ b/routes/notifikasi-wa.route.js @@ -14,10 +14,10 @@ router.post('/restart-wa', async (req, res) => { } }); -router.post('/reminder-monthly/:id',verifyToken, verifyAccess, async (req, res) => { +router.post('/reminder-monthly/:id', verifyToken.verifyAccessToken, verifyAccess(), async (req, res) => { try { const { id } = req.params; - const {reminder_at_monthly} = req.body + const { reminder_at_monthly } = req.body; const result = await NotifikasiWaService.onMonthlyReminder(id, reminder_at_monthly); return res.status(200).json(result); } catch (error) { @@ -25,10 +25,10 @@ router.post('/reminder-monthly/:id',verifyToken, verifyAccess, async (req, res) } }); -router.post('/reminder-custom/:id',verifyToken, verifyAccess, async (req, res) => { +router.post('/reminder-custom/:id', verifyToken.verifyAccessToken, verifyAccess(), async (req, res) => { try { const { id } = req.params; - const {start_date, end_date} = req.body; + const { start_date, end_date } = req.body; const result = await NotifikasiWaService.onCustomReminder(id, start_date, end_date); return res.status(200).json(result); } catch (error) { -- 2.49.1