Merged in release/2025-02-28 (pull request #2124)

release/2025-02-28

Approved-by: Patrick Fic
This commit is contained in:
Patrick Fic
2025-02-20 23:38:06 +00:00
2 changed files with 31 additions and 7 deletions

View File

@@ -92,7 +92,7 @@ const sendTaskEmail = async ({ to, subject, type = "text", html, text, attachmen
},
(err, info) => {
// (message, type, user, record, meta
logger.log("server-email", err ? "error" : "debug", null, null, { message: err || info });
logger.log("server-email", err ? "error" : "debug", null, null, { message: err ? err?.message : info });
}
);
} catch (error) {
@@ -239,24 +239,24 @@ const emailBounce = async (req, res) => {
return;
}
//If it's bounced, log it as bounced in audit log. Send an email to the user.
const result = await client.request(queries.UPDATE_EMAIL_AUDIT, {
await client.request(queries.UPDATE_EMAIL_AUDIT, {
sesid: messageId,
status: "Bounced",
context: message.bounce?.bouncedRecipients
});
mailer.sendMail(
{
from: InstanceMgr({
from: InstanceManager({
imex: `ImEX Online <noreply@imex.online>`,
rome: `Rome Online <noreply@romeonline.io>`
}),
to: replyTo,
//bcc: "patrick@snapt.ca",
subject: `${InstanceMgr({
subject: `${InstanceManager({
imex: "ImEX Online",
rome: "Rome Online"
})} Bounced Email - RE: ${subject}`,
text: `${InstanceMgr({
text: `${InstanceManager({
imex: "ImEX Online",
rome: "Rome Online"
})} has tried to deliver an email with the subject: ${subject} to the intended recipients but encountered an error.
@@ -270,7 +270,7 @@ ${body.bounce?.bouncedRecipients.map(
},
(err, info) => {
logger.log("sns-error", err ? "error" : "debug", "api", null, {
message: err ? JSON.stringify(error) : info
message: err ? err?.message : info
});
}
);

View File

@@ -25,6 +25,10 @@ async function OpenSearchUpdateHandler(req, res) {
switch (req.body.table.name) {
case "jobs":
logger.log("os-handler-jobs", "DEBUG", req.user.email, null, {
jobid: req.body.event.data.new.id,
bodyshopid: req.body.event.data.new.shopid
});
document = pick(req.body.event.data.new, [
"id",
"bodyshopid",
@@ -49,6 +53,10 @@ async function OpenSearchUpdateHandler(req, res) {
document.bodyshopid = req.body.event.data.new.shopid;
break;
case "vehicles":
logger.log("os-handler-vehicles", "DEBUG", req.user.email, null, {
vehicleid: req.body.event.data.new.id,
bodyshopid: req.body.event.data.new.shopid
});
document = pick(req.body.event.data.new, [
"id",
"v_model_yr",
@@ -61,6 +69,10 @@ async function OpenSearchUpdateHandler(req, res) {
document.bodyshopid = req.body.event.data.new.shopid;
break;
case "owners":
logger.log("os-handler-owners", "DEBUG", req.user.email, null, {
ownerid: req.body.event.data.new.id,
bodyshopid: req.body.event.data.new.shopid
});
document = pick(req.body.event.data.new, ["id", "ownr_fn", "ownr_ln", "ownr_co_nm", "ownr_ph1", "ownr_ph2"]);
document.bodyshopid = req.body.event.data.new.shopid;
break;
@@ -96,9 +108,15 @@ async function OpenSearchUpdateHandler(req, res) {
...bill.bills_by_pk,
bodyshopid: bill.bills_by_pk.job.shopid
};
logger.log("os-handler-bills", "DEBUG", req.user.email, null, {
billid: req.body.event.data.new.id,
bodyshopid: bill.bills_by_pk.job.shopid
});
break;
case "payments":
//Query to get the job and RO number
const payment = await client.request(
`query ADMIN_GET_PAYMENT_BY_ID($paymentId: uuid!) {
payments_by_pk(id: $paymentId) {
@@ -139,6 +157,10 @@ async function OpenSearchUpdateHandler(req, res) {
...payment.payments_by_pk,
bodyshopid: payment.payments_by_pk.job.shopid
};
logger.log("os-handler-payments", "DEBUG", req.user.email, null, {
paymentid: req.body.event.data.new.id,
bodyshopid: payment.payments_by_pk.job.shopid
});
break;
}
const payload = {
@@ -166,7 +188,9 @@ async function OpenSearchSearchHandler(req, res) {
}
logger.log("os-search", "DEBUG", req.user.email, null, {
search
search,
index,
bodyshopid
});
const BearerToken = req.BearerToken;