diff --git a/wai-server/core/handler/whatsappHandler.js b/wai-server/core/handler/whatsappHandler.js index ac726df..063d465 100644 --- a/wai-server/core/handler/whatsappHandler.js +++ b/wai-server/core/handler/whatsappHandler.js @@ -168,7 +168,7 @@ const setupMessageHandler = () => { // todo: 现在只能收text 消息, 后续再加其他类型 const msgRow = await upsertOutboundMessage( - { ...timeFields, ...upsertFields, ...pusher, ...contentFields, ...record, type: _type, message_origin: savedMsg?.message_origin || JSON.stringify(messageData) }, + { ...timeFields, ...upsertFields, ...pusher, ...contentFields, ...record, ...typeField, message_origin: savedMsg?.message_origin || JSON.stringify(messageData) }, targetUpsert, ); // console.log('upsert=========================', upsert); diff --git a/wai-server/helper/wai.msg.helper.js b/wai-server/helper/wai.msg.helper.js index 018486c..0a4fbed 100644 --- a/wai-server/helper/wai.msg.helper.js +++ b/wai-server/helper/wai.msg.helper.js @@ -52,6 +52,7 @@ const mediaMsg = { caption: row.IVADS_caption, filename: row.IVADS_filename, }, + type: row.msgtype, ...(row.context_id ? { context: { message_id: row.context_id, from: row.context_from } } : {}), }), }; @@ -89,6 +90,7 @@ const waiMsgTypeMapped = { }; }, DbData: row => ({ + type: 'text', text: { body: row.text_body, preview_url: row.text_preview_url }, ...(row.context_id ? { context: { message_id: row.context_id, from: row.context_from } } : {}), }), @@ -159,6 +161,7 @@ const waiMsgTypeMapped = { }; }, DbData: row => ({ + type: 'reaction', reaction: { emoji: row.reaction_emoji, message_id: row.reaction_message_id }, }), }, @@ -183,6 +186,7 @@ const waiMsgTypeMapped = { }; }, DbData: row => ({ + type: 'location', location: { latitude: row.location_latitude, longitude: row.location_longitude, @@ -214,6 +218,7 @@ const waiMsgTypeMapped = { }; }, DbData: row => ({ + type: 'contacts', contacts: JSON.parse(row.contacts), }), },