fixing body message notification wa
This commit is contained in:
@@ -7,7 +7,7 @@ const {
|
||||
updateNotificationErrorDb,
|
||||
} = require("../db/notification_error.db");
|
||||
|
||||
const { getErrorCodeByIdDb } = require("../db/brand_code.db");
|
||||
const { getErrorCodeByIdDb, getErrorCodeByBrandAndCodeDb } = require("../db/brand_code.db");
|
||||
|
||||
const { getSolutionsByErrorCodeIdDb } = require("../db/brand_code_solution.db");
|
||||
|
||||
@@ -175,7 +175,7 @@ class NotificationService {
|
||||
const deviceNotification = await getNotificationByIdDb(id);
|
||||
if (!deviceNotification) throw new ErrorHandler(404, "Data not found");
|
||||
|
||||
const errorCode = await getErrorCodeByIdDb(
|
||||
const errorCode = await getErrorCodeByBrandAndCodeDb(deviceNotification?.brand_id ?? 0,
|
||||
deviceNotification.error_code_id
|
||||
);
|
||||
const dataExist = await getUsersNotificationErrorDb(id);
|
||||
@@ -208,7 +208,7 @@ class NotificationService {
|
||||
|
||||
const sendPromises = activeUsers.map(async (user) => {
|
||||
try {
|
||||
console.log(`user: ${user.contact_name} (${user.contact_phone})`);
|
||||
console.log(`user: ${user.contact_name} (${user.contact_phone})`);
|
||||
const tokenRedirect = await generateTokenRedirect(
|
||||
user.contact_phone,
|
||||
user.contact_name,
|
||||
@@ -221,17 +221,17 @@ class NotificationService {
|
||||
console.log("URL:", shortUrl);
|
||||
|
||||
const bodyWithUrl =
|
||||
`Hai ${user.contact_name || "-"}\n` +
|
||||
`Terjadi peringatan dengan kode ${errorCode?.error_code || "-"} - ${
|
||||
errorCode?.error_code_name
|
||||
} pada device ${deviceNotification.device_name || "-"}.\n` +
|
||||
`Silahkan cek detail pada link berikut:\n ${shortUrl}`;
|
||||
`Hai ${user.contact_name || "-"},\n` +
|
||||
`Terjadi peringatan dengan kode ${errorCode?.error_code ?? "-"} "${errorCode?.error_code_name}", Chanel ${deviceNotification?.error_chanel ?? "-"} ` +
|
||||
`pada device ${deviceNotification.device_name ?? "berikut"}` +
|
||||
`\nSilahkan cek detail pada link :` +
|
||||
`${shortUrl}`;
|
||||
|
||||
const resultSend = await sendNotifikasi(
|
||||
user.contact_phone,
|
||||
bodyWithUrl
|
||||
);
|
||||
|
||||
|
||||
console.log("notifikasi wa:", resultSend)
|
||||
|
||||
const isSuccess = resultSend.success;
|
||||
@@ -256,8 +256,7 @@ class NotificationService {
|
||||
console.log("result akhir: ", results)
|
||||
|
||||
console.log(
|
||||
`Resend chat: ${
|
||||
results.filter((r) => r.status === "success").length
|
||||
`Resend chat: ${results.filter((r) => r.status === "success").length
|
||||
}, Gagal: ${results.filter((r) => r.status === "failed").length}`
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user