fixing is delivered notification wa
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
const { getAllContactDb } = require("../db/contact.db");
|
||||
const { InsertNotificationErrorDb } = require("../db/notification_error.db");
|
||||
const { InsertNotificationErrorDb, updateNotificationErrorDb } = require("../db/notification_error.db");
|
||||
const {
|
||||
createNotificationErrorUserDb,
|
||||
updateNotificationErrorUserDb,
|
||||
@@ -65,6 +65,8 @@ class NotifikasiWaService {
|
||||
|
||||
const resultNotificationError = await InsertNotificationErrorDb(data);
|
||||
|
||||
let isSendNotification = false
|
||||
|
||||
for (const dataUser of dataUsers) {
|
||||
if (dataUser.is_active) {
|
||||
const tokenRedirect = await generateTokenRedirect(
|
||||
@@ -79,7 +81,7 @@ class NotifikasiWaService {
|
||||
|
||||
const bodyMessage =
|
||||
`Hai ${dataUser.contact_name || "-"}\n` +
|
||||
`Terjadi kode error ${chanel?.value ?? "-"} ${errorCode?.error_code_name ?? ""} Chanel ${chanel?.chanel_id ?? "-"} ` +
|
||||
`Terjadi kode error ${chanel?.value ?? "-"} ${errorCode?.error_code_name ?? ""}Chanel ${chanel?.chanel_id ?? "-"} ` +
|
||||
`pada device ${deviceNotification?.device_name ?? "berikut"
|
||||
}, Silahkan cek detail pada link berikut:\n` +
|
||||
`${shortUrl}`;
|
||||
@@ -105,14 +107,28 @@ class NotifikasiWaService {
|
||||
param.bodyMessage
|
||||
);
|
||||
|
||||
|
||||
|
||||
await updateNotificationErrorUserDb(
|
||||
resultNotificationErrorUser[0].notification_error_user_id,
|
||||
{
|
||||
is_send: resultSend?.success ? true : false,
|
||||
is_send: resultSend.success,
|
||||
}
|
||||
);
|
||||
|
||||
if (resultSend.success) {
|
||||
isSendNotification = resultSend.success
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await updateNotificationErrorDb(
|
||||
resultNotificationError.notification_error_id,
|
||||
{
|
||||
is_send: isSendNotification,
|
||||
is_delivered: isSendNotification,
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user