Skip to content
Closed
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
50 changes: 32 additions & 18 deletions src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4250,24 +4250,38 @@
}

private prepareMessage(message: proto.IWebMessageInfo): any {
const contentType = getContentType(message.message);
const contentMsg = message?.message[contentType] as any;

const messageRaw = {
key: message.key,
pushName:
message.pushName ||
(message.key.fromMe
? 'Você'
: message?.participant || (message.key?.participant ? message.key.participant.split('@')[0] : null)),
status: status[message.status],
message: { ...message.message },
contextInfo: contentMsg?.contextInfo,
messageType: contentType || 'unknown',
messageTimestamp: message.messageTimestamp as number,
instanceId: this.instanceId,
source: getDevice(message.key.id),
};
const contentType = getContentType(message.message);

Check failure on line 4253 in src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

View workflow job for this annotation

GitHub Actions / check-lint-and-build

Insert `··`

const mm = message.message as Record<string, any> | undefined;

Check failure on line 4255 in src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

View workflow job for this annotation

GitHub Actions / check-lint-and-build

Insert `··`
const contentCtx =

Check failure on line 4256 in src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

View workflow job for this annotation

GitHub Actions / check-lint-and-build

Replace `··` with `····`
contentType && mm && typeof mm[contentType] === 'object'

Check failure on line 4257 in src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

View workflow job for this annotation

GitHub Actions / check-lint-and-build

Replace `····contentType·&&·mm·&&·typeof·mm[contentType]·===·'object'⏎······?·mm[contentType]?.contextInfo⏎·····` with `······contentType·&&·mm·&&·typeof·mm[contentType]·===·'object'·?·mm[contentType]?.contextInfo`
? mm[contentType]?.contextInfo
: undefined;

const mergedContext: Record<string, any> = {

Check failure on line 4261 in src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

View workflow job for this annotation

GitHub Actions / check-lint-and-build

Insert `··`
...(contentCtx || {}),

Check failure on line 4262 in src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

View workflow job for this annotation

GitHub Actions / check-lint-and-build

Replace `····` with `······`
...(message.message?.contextInfo || {}),

Check failure on line 4263 in src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

View workflow job for this annotation

GitHub Actions / check-lint-and-build

Insert `··`
...(message.messageContextInfo || {}),

Check failure on line 4264 in src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

View workflow job for this annotation

GitHub Actions / check-lint-and-build

Replace `····` with `······`
};

Check failure on line 4265 in src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

View workflow job for this annotation

GitHub Actions / check-lint-and-build

Insert `··`

const contextInfoFinal = Object.keys(mergedContext).length > 0 ? mergedContext : undefined;

Check failure on line 4267 in src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts

View workflow job for this annotation

GitHub Actions / check-lint-and-build

Insert `··`

const messageRaw = {
key: message.key,
pushName:
message.pushName ||
(message.key.fromMe
? 'Você'
: message?.participant ||
(message.key?.participant ? message.key.participant.split('@')[0] : null)),
status: status[message.status],
message: { ...message.message },
contextInfo: contextInfoFinal,
messageType: contentType || 'unknown',
messageTimestamp: message.messageTimestamp as number,
instanceId: this.instanceId,
source: getDevice(message.key.id),
};

if (!messageRaw.status && message.key.fromMe === false) {
messageRaw.status = status[3]; // DELIVERED MESSAGE
Expand Down