|
|
|
@ -36,6 +36,7 @@ const webhookBodyBuilder = (messageData, messageType) => {
|
|
|
|
|
wamid: messageData.id,
|
|
|
|
|
direction: directionField[messageType],
|
|
|
|
|
// externalId: '-1', // todo:
|
|
|
|
|
externalId: `-${messageData.externalId || 1}`, // debug: 测试: 是负值
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
return message;
|
|
|
|
@ -80,7 +81,7 @@ const setupConnectionHandler = () => {
|
|
|
|
|
...objectMapper(connectionData, { whatsAppNo: [{ key: 'wa_id' }, { key: 'sesson_id' }], channelId: 'channel_id' }),
|
|
|
|
|
service_type: 'baileys',
|
|
|
|
|
},
|
|
|
|
|
{ connect_domain: domain },
|
|
|
|
|
{ connect_domain: domain, connect_name: domainName },
|
|
|
|
|
);
|
|
|
|
|
// todo: 通知前端: 重新扫码
|
|
|
|
|
} catch (error) {
|
|
|
|
@ -97,10 +98,10 @@ const setupMessageHandler = () => {
|
|
|
|
|
try {
|
|
|
|
|
const m = await getOutboundMessage({ id: messageData.id });
|
|
|
|
|
|
|
|
|
|
const webhookBody = webhookBodyBuilder({ ...messageData, actionId: m.actionId, externalId: m.externalId }, eventName);
|
|
|
|
|
const webhookBody = webhookBodyBuilder({ actionId: m.actionId || '', externalId: m.externalId || '', ...messageData }, eventName);
|
|
|
|
|
const { waiMessage } = webhookBody;
|
|
|
|
|
|
|
|
|
|
const upsert = await upsertOutboundMessage(m.sn, { ...waiMessage, msg_status: waiMessage.status });
|
|
|
|
|
const upsert = await upsertOutboundMessage(m.sn || null, { ...waiMessage, msg_status: waiMessage.status });
|
|
|
|
|
// console.log('upsert=========================', upsert);
|
|
|
|
|
await callWebhook(webhookBody);
|
|
|
|
|
} catch (error) {
|
|
|
|
|