fix: update notification error handling to include new update method and improve reminder deletion logic
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user