Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5184,6 +5184,21 @@ export class BaileysStartupService extends ChannelStartupService {
if (messageRaw.message.extendedTextMessage) {
messageRaw.messageType = 'conversation';
messageRaw.message.conversation = messageRaw.message.extendedTextMessage.text;

/**
* Keep the reply metadata before dropping the wrapper.
*
* `stanzaId`, `participant` and `quotedMessage` live inside the
* extendedTextMessage's own contextInfo. Deleting the wrapper dropped
* them, so every text reply reached webhooks and the database unquoted,
* while media replies (never flattened) kept theirs.
*/
const quotedContext = messageRaw.message.extendedTextMessage.contextInfo;

if (quotedContext) {
messageRaw.contextInfo = { ...(messageRaw.contextInfo ?? {}), ...quotedContext };
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
}

delete messageRaw.message.extendedTextMessage;
}

Expand Down Expand Up @@ -5685,12 +5700,22 @@ export class BaileysStartupService extends ChannelStartupService {
if (!message.pushName) {
if (messageKey.fromMe) {
message.pushName = 'VocΓͺ';
} else if (messageKey.participant) {
/**
* The sender comes from the message key.
*
* `contextInfo.participant` is the author of the QUOTED message, not
* of this one, so it may only stand in when the key carries nothing.
* It used to be checked first, which was harmless while contextInfo
* never carried a participant β€” and would mislabel the sender of a
* text reply now that the quote is preserved.
*/
message.pushName = messageKey.participant.split('@')[0];
} else if (message.contextInfo) {
const contextInfo = message.contextInfo as { participant?: string };

if (contextInfo.participant) {
message.pushName = contextInfo.participant.split('@')[0];
} else if (messageKey.participant) {
message.pushName = messageKey.participant.split('@')[0];
}
}
}
Expand Down