From ec20df7dc4aa57e7479bdd0c6d8975f97dc04eff Mon Sep 17 00:00:00 2001 From: Lei OT Date: Thu, 9 Oct 2025 14:30:00 +0800 Subject: [PATCH] =?UTF-8?q?perf(WAI):=20=E5=BC=95=E7=94=A8=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=E7=9A=84=E4=B8=8D=E5=8F=91=E9=80=81context=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wai-server/helper/wai.msg.helper.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/wai-server/helper/wai.msg.helper.js b/wai-server/helper/wai.msg.helper.js index 2f2c0dd..eadbbaa 100644 --- a/wai-server/helper/wai.msg.helper.js +++ b/wai-server/helper/wai.msg.helper.js @@ -2,7 +2,7 @@ * */ 'use strict'; -const { objectMapper, pick } = require('../utils/commons.util'); +const { objectMapper, pick, isEmpty } = require('../utils/commons.util'); const mediaMsg = { contentToSend: msg => { @@ -48,7 +48,7 @@ const mediaMsg = { IVADS_link: msgcontent[msgtype].link, IVADS_caption: msgcontent[msgtype].caption || '', IVADS_filename: msgcontent[msgtype].filename || '', - ...(msgcontent.context + ...(!isEmpty(msgcontent.context) ? { context_id: msgcontent.context.message_id, context_from: msgcontent.message_origin.from, @@ -67,7 +67,7 @@ const mediaMsg = { mime_type: row.IVADS_mime_type ?? '', }, type: row.msgtype, - ...(row.context_id ? { context: { id: row.context_id, from: row.context_from } } : {}), + ...(!isEmpty(row.context_id) ? { context: { id: row.context_id, from: row.context_from } } : {}), }), }; @@ -89,14 +89,14 @@ const waiMsgTypeMapped = { externalId: msg.actionId, text: msg.msgcontent.body, // linkPreview: true, // {} - ...(msg.msgcontent.context ? { quoted: { key: msg.msgcontent.context.message_id } } : {}), + ...(!isEmpty(msg.msgcontent.context) ? { quoted: { key: msg.msgcontent.context.message_id } } : {}), }), waiContentToDB: msg => { return { text_body: msg.text.body, actionId: msg?.externalId, externalId: (msg?.externalId || '').split('.')?.[0], - ...(msg.context + ...(!isEmpty(msg.context) ? { context_id: msg.context.id, context_from: msg.context.from, @@ -115,7 +115,7 @@ const waiMsgTypeMapped = { ...record, text_body: msgcontent.body, text_preview_url: msgcontent.preview_url, - ...(msgcontent.context + ...(!isEmpty(msgcontent.context) ? { context_id: msgcontent.context.message_id, context_from: msgcontent.message_origin.from, @@ -127,7 +127,7 @@ const waiMsgTypeMapped = { DbData: row => ({ type: 'text', text: { body: row.text_body, preview_url: row.text_preview_url }, - ...(row.context_id ? { context: { id: row.context_id, from: row.context_from } } : {}), + ...(!isEmpty(row.context_id) ? { context: { id: row.context_id, from: row.context_from } } : {}), }), }, image: {