add: params contact_phone and validation resend chat wa in notif error user

This commit is contained in:
2026-01-01 18:31:09 +07:00
parent 889aa04808
commit bedc948a74
3 changed files with 19 additions and 12 deletions

View File

@@ -34,7 +34,7 @@ class NotificationErrorUserService {
const result = await getNotificationErrorUserByIdDb(id);
if (result.length < 1)
throw new ErrorHandler(404, "NotificationErrorUser not found");
throw new ErrorHandler(404, "Notification Error User not found");
return result;
} catch (error) {
@@ -63,7 +63,7 @@ class NotificationErrorUserService {
const dataExist = await getNotificationErrorUserByIdDb(id);
if (dataExist.length < 1) {
throw new ErrorHandler(404, "NotificationErrorUser not found");
throw new ErrorHandler(404, "Notification Error User not found");
}
const result = await updateNotificationErrorUserDb(id, data);
@@ -80,7 +80,7 @@ class NotificationErrorUserService {
const dataExist = await getNotificationErrorUserByIdDb(id);
if (dataExist.length < 1) {
throw new ErrorHandler(404, "NotificationErrorUser not found");
throw new ErrorHandler(404, "Notification Error User not found");
}
const result = await deleteNotificationErrorUserDb(id, userId);
@@ -91,23 +91,30 @@ class NotificationErrorUserService {
}
}
static async resendNotification(id) {
static async resendNotification(id, contact_phone) {
try {
const dataExist = await getNotificationErrorUserByIdDb(id);
if (!dataExist || dataExist.length < 1) {
throw new ErrorHandler(
404,
"Data Notification Error User tidak ditemukan"
"Data Notification Error User not found"
);
}
const data = dataExist[0];
if (data.contact_is_active === 1) {
if (data.contact_phone !== contact_phone) {
throw new ErrorHandler(
404,
`Contact Phone with this phone ${contact_phone} not found.`
);
}
if (data.contact_is_active === false) {
throw new ErrorHandler(
400,
`Kontak dengan nomor ${
data.contact_phone || "terkait"
} tidak aktif.`
`Contact Phone with this phone ${data.contact_phone} not active.`
);
}