diff --git a/src/Socket/messages-send.ts b/src/Socket/messages-send.ts index 2671aac3..ff8c4415 100644 --- a/src/Socket/messages-send.ts +++ b/src/Socket/messages-send.ts @@ -169,7 +169,7 @@ export const makeMessagesSocket = (config: SocketConfig) => { node.attrs.t = unixTimestampSeconds().toString() } - if (type === 'sender' && (isAnyPnUser(jid) || isAnyLidUser(jid))) { + if (type === 'sender' && (isPnUser(jid) || isLidUser(jid))) { node.attrs.recipient = jid node.attrs.to = participant! } else { @@ -1244,9 +1244,10 @@ export const makeMessagesSocket = (config: SocketConfig) => { // Only inject for actual user JIDs, not broadcasts, newsletters, or Meta AI bots // IMPORTANT: Carousels and catalog messages should NOT have bot node // as they are regular interactive messages, not bot messages + // NOTE: Only for regular JIDs, NOT hosted JIDs (to avoid interference with interactive messages) const isPrivateUserChat = ( - isAnyPnUser(destinationJid) || - isAnyLidUser(destinationJid) || + isPnUser(destinationJid) || + isLidUser(destinationJid) || destinationJid?.endsWith('@c.us') ) && !isJidBot(destinationJid) diff --git a/src/Utils/generics.ts b/src/Utils/generics.ts index 9f74429f..55b37f24 100644 --- a/src/Utils/generics.ts +++ b/src/Utils/generics.ts @@ -128,7 +128,6 @@ export const debouncedTimeout = (intervalMs = 1000, task?: () => void) => { export const delay = (ms: number) => delayCancellable(ms).delay export const delayCancellable = (ms: number) => { - const stack = new Error().stack let timeout: NodeJS.Timeout let reject: (error: any) => void const delay: Promise = new Promise((resolve, _reject) => { @@ -137,14 +136,9 @@ export const delayCancellable = (ms: number) => { }) const cancel = () => { clearTimeout(timeout) - reject( - new Boom('Cancelled', { - statusCode: 500, - data: { - stack - } - }) - ) + // Boom creates native Error instances and calls Error.captureStackTrace() + // The .stack property is preserved automatically + reject(new Boom('Cancelled', { statusCode: 500 })) } return { delay, cancel } @@ -158,18 +152,16 @@ export async function promiseTimeout( return new Promise(promise) } - const stack = new Error().stack // Create a promise that rejects in milliseconds + // Boom creates native Error instances and calls Error.captureStackTrace() + // The .stack property is preserved automatically const { delay, cancel } = delayCancellable(ms) const p = new Promise((resolve, reject) => { delay .then(() => reject( new Boom('Timed Out', { - statusCode: DisconnectReason.timedOut, - data: { - stack - } + statusCode: DisconnectReason.timedOut }) ) )