Merge pull request 'fixing is delivered notification wa' (#41) from wisdom into main
Reviewed-on: #41
This commit is contained in:
@@ -131,17 +131,17 @@ const getAllNotificationDb = async (searchParams = {}) => {
|
|||||||
|
|
||||||
FROM notification_error a
|
FROM notification_error a
|
||||||
|
|
||||||
|
LEFT JOIN m_device d
|
||||||
|
ON a.error_chanel = d.listen_channel AND d.deleted_at IS NULL
|
||||||
|
|
||||||
LEFT JOIN brand_code b
|
LEFT JOIN brand_code b
|
||||||
ON a.error_code_id = b.error_code_id AND b.deleted_at IS NULL
|
ON a.error_code_id = b.error_code AND b.deleted_at IS NULL AND d.brand_id = b.brand_id
|
||||||
|
|
||||||
LEFT JOIN brand_code_solution c
|
LEFT JOIN brand_code_solution c
|
||||||
ON b.error_code_id = c.error_code_id AND c.deleted_at IS NULL
|
ON b.error_code_id = c.error_code_id AND c.deleted_at IS NULL
|
||||||
|
|
||||||
LEFT JOIN m_device d
|
|
||||||
ON a.error_chanel = d.listen_channel AND d.deleted_at IS NULL
|
|
||||||
|
|
||||||
LEFT JOIN m_brands e
|
LEFT JOIN m_brands e
|
||||||
ON d.brand_id = e.brand_id AND d.deleted_at IS NULL
|
ON d.brand_id = e.brand_id AND e.deleted_at IS NULL
|
||||||
|
|
||||||
WHERE a.deleted_at IS NULL
|
WHERE a.deleted_at IS NULL
|
||||||
${whereConditions.length > 0 ? ` AND ${whereConditions.join(" AND ")}` : ""}
|
${whereConditions.length > 0 ? ` AND ${whereConditions.join(" AND ")}` : ""}
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ class NotificationService {
|
|||||||
|
|
||||||
console.log("notifikasi wa:", resultSend)
|
console.log("notifikasi wa:", resultSend)
|
||||||
|
|
||||||
const isSuccess = resultSend?.success ? true : false;
|
const isSuccess = resultSend.success;
|
||||||
|
|
||||||
await updateNotificationErrorDb(user.notification_error_id, {
|
await updateNotificationErrorDb(user.notification_error_id, {
|
||||||
is_send: isSuccess,
|
is_send: isSuccess,
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ class NotificationErrorUserService {
|
|||||||
data.contact_phone,
|
data.contact_phone,
|
||||||
bodyWithUrl
|
bodyWithUrl
|
||||||
);
|
);
|
||||||
const isSuccess = resultSend?.success ? true : false;
|
const isSuccess = resultSend.success;
|
||||||
|
|
||||||
const updateData = {
|
const updateData = {
|
||||||
is_send: isSuccess,
|
is_send: isSuccess,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const { getAllContactDb } = require("../db/contact.db");
|
const { getAllContactDb } = require("../db/contact.db");
|
||||||
const { InsertNotificationErrorDb } = require("../db/notification_error.db");
|
const { InsertNotificationErrorDb, updateNotificationErrorDb } = require("../db/notification_error.db");
|
||||||
const {
|
const {
|
||||||
createNotificationErrorUserDb,
|
createNotificationErrorUserDb,
|
||||||
updateNotificationErrorUserDb,
|
updateNotificationErrorUserDb,
|
||||||
@@ -65,6 +65,8 @@ class NotifikasiWaService {
|
|||||||
|
|
||||||
const resultNotificationError = await InsertNotificationErrorDb(data);
|
const resultNotificationError = await InsertNotificationErrorDb(data);
|
||||||
|
|
||||||
|
let isSendNotification = false
|
||||||
|
|
||||||
for (const dataUser of dataUsers) {
|
for (const dataUser of dataUsers) {
|
||||||
if (dataUser.is_active) {
|
if (dataUser.is_active) {
|
||||||
const tokenRedirect = await generateTokenRedirect(
|
const tokenRedirect = await generateTokenRedirect(
|
||||||
@@ -105,15 +107,29 @@ class NotifikasiWaService {
|
|||||||
param.bodyMessage
|
param.bodyMessage
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
await updateNotificationErrorUserDb(
|
await updateNotificationErrorUserDb(
|
||||||
resultNotificationErrorUser[0].notification_error_user_id,
|
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) {
|
} catch (error) {
|
||||||
// throw new ErrorHandler(error.statusCode, error.message);
|
// throw new ErrorHandler(error.statusCode, error.message);
|
||||||
|
|||||||
Reference in New Issue
Block a user