diff --git a/src/channel/bubbleMsgUtils.js b/src/channel/bubbleMsgUtils.js index 8d52b9e..71422e8 100644 --- a/src/channel/bubbleMsgUtils.js +++ b/src/channel/bubbleMsgUtils.js @@ -377,7 +377,7 @@ export const whatsappMsgTypeMapped = { }, system: { type: 'system', - data: (msg) => ({ id: msg.wamid, text: msg.system.body }), + data: (msg) => ({ id: msg.wamid, text: msg.system?.body }), }, text: { type: 'text', @@ -515,14 +515,14 @@ export const whatsappMsgTypeMapped = { data: (msg) => ({ id: msg.wamid, meetingID: msg.wamid, - title: msg.contacts.length === 1 ? `联系人` : `${msg.contacts.length} 位联系人`, - text: msg.contacts.map((ele) => `${(ele?.org?.company || '') +' '+ele.name.formatted_name}: ${ele.phones[0].wa_id || ele.phones[0].phone}`).join('\n'), - data: msg.contacts.map((ele) => ({ id: ele.phones[0]?.wa_id || ele.phones[0].phone, wa_id: ele.phones[0]?.wa_id || '', phone: ele.phones[0].phone, name: (ele?.org?.company || '') +' '+ele.name.formatted_name })), - waBtn: msg.contacts.some(ele => ele.phones.some(p => p.wa_id)), + title: (msg.contacts || []).length === 1 ? `联系人` : `${(msg.contacts || []).length} 位联系人`, + text: (msg.contacts || []).map((ele) => `${(ele?.org?.company || '') +' '+ele.name.formatted_name}: ${ele.phones[0].wa_id || ele.phones[0].phone}`).join('\n'), + data: (msg.contacts || []).map((ele) => ({ id: ele.phones[0]?.wa_id || ele.phones[0].phone, wa_id: ele.phones[0]?.wa_id || '', phone: ele.phones[0].phone, name: (ele?.org?.company || '') +' '+ele.name.formatted_name })), + waBtn: (msg.contacts || []).some(ele => ele.phones.some(p => p.wa_id)), }), renderForReply: (msg) => ({ id: msg.wamid, - message: '[联系人] ' + msg.contacts[0].name.formatted_name + '...', + message: '[联系人] ' + msg.contacts?.[0].name.formatted_name + '...', }), }, location: {