perf(WAI): 解析有引用的消息

main
Lei OT 7 months ago
parent 44b9d930dc
commit 12feaa7780

@ -46,6 +46,7 @@ const createWhatsApp = async phone => {
const { state, saveCreds } = await useMultiFileAuthState(authStateFolder);
// fetch latest version of WA Web
// const { version, isLatest } = await fetchLatestBaileysVersion();
// const { version, isLatest } = await fetchLatestWaWebVersion();
const { version, isLatest, } = { version: [2, 3000, 1025091846], isLatest: false };
const waVersion = version.join('.') + ', ' + (isLatest ? 'latest' : 'out');
@ -107,15 +108,21 @@ const createWhatsApp = async phone => {
text: {
body: text,
},
context: {
from: decodeJid(original.message?.extendedTextMessage?.contextInfo?.participant),
id: original.message?.extendedTextMessage?.contextInfo?.stanzaId,
},
};
};
const parseReactionMessage = original => {
const text = original.message?.reactionMessage?.text;
const context = original.message?.reactionMessage?.key?.id;
return {
type: 'text',
text: {
body: text,
type: 'reaction',
reaction: {
message_id: context,
emoji: text,
},
};
};

@ -89,7 +89,17 @@ const waiMsgTypeMapped = {
...(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] };
return {
text_body: msg.text.body,
actionId: msg?.externalId,
externalId: (msg?.externalId || '').split('.')?.[0],
...(msg.context
? {
context_id: msg.context.id,
context_from: msg.context.from,
}
: {}),
};
},
dataToDB: msg => {
const { msgcontent } = msg;
@ -162,22 +172,21 @@ const waiMsgTypeMapped = {
dataToDB: msg => mediaMsg.dataToDB(msg),
DbData: msg => mediaMsg.DbData(msg),
},
react: {
type: 'react',
reaction: {
type: 'reaction',
contentToSend: msg => ({
// ...msg,
to: msg.to,
externalId: msg.actionId,
react: {
reaction: {
text: msg.msgcontent.body, // emoji | use an empty string to remove the reaction
key: msg.msgcontent.context.message_id,
},
}),
waiContentToDB: msg => {
return {
// todo:
reaction_message_id: '',
reaction_emoji: '',
reaction_message_id: msg?.reaction?.message_id || '',
reaction_emoji: msg?.reaction?.emoji || '',
actionId: msg?.externalId,
externalId: (msg?.externalId || '').split('.')?.[0],
};

Loading…
Cancel
Save