wisdom #22

Merged
bragaz_rexita merged 5 commits from wisdom into main 2026-01-05 04:25:09 +00:00
3 changed files with 19 additions and 12 deletions
Showing only changes of commit bedc948a74 - Show all commits

View File

@@ -69,9 +69,9 @@ class NotificationErrorUserController {
static async resend(req, res) { static async resend(req, res) {
try { try {
const { id } = req.params; const { id, contact_phone } = req.params;
const results = await NotificationErrorUserService.resendNotification(id); const results = await NotificationErrorUserService.resendNotification(id, contact_phone);
const response = await setResponse( const response = await setResponse(
results.data, results.data,

View File

@@ -29,7 +29,7 @@ router
); );
router.post( router.post(
"/resend/:id", "/resend/:id/:contact_phone",
verifyToken.verifyAccessToken, verifyToken.verifyAccessToken,
verifyAccess(), verifyAccess(),
NotificationErrorUserController.resend NotificationErrorUserController.resend

View File

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