fix: update notification error handling to include new update method and improve reminder deletion logic

This commit is contained in:
2026-05-03 19:26:51 +07:00
parent abbce10e32
commit acb084475d
5 changed files with 198 additions and 83 deletions

View File

@@ -5,7 +5,9 @@ const {
updateDeviceDb,
deleteDeviceDb
} = require('../db/device.db');
const { updateNotificationErrorByChanelReminderDb } = require('../db/notification_error.db');
const { ErrorHandler } = require('../helpers/error');
const notifikasiWaService = require('./notifikasi-wa.service');
class DeviceService {
// Get all devices
@@ -59,6 +61,17 @@ class DeviceService {
throw new ErrorHandler(404, 'Device not found');
}
const updateStatus = await updateNotificationErrorByChanelReminderDb(
Number(dataExist[0].listen_channel_reminder),
{ is_active: 0, userId: data.userId }
);
await notifikasiWaService.deleteReminderByChanelReminder(Number(dataExist[0].listen_channel_reminder));
if (!updateStatus) {
throw new ErrorHandler(500, 'Failed to update notification');
}
const result = await updateDeviceDb(id, data);
return result;