Skip to content

Commit

Permalink
fix: get message id for typebot
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidsonGomes committed Jun 10, 2024
1 parent fa3306b commit a8937bd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
11 changes: 7 additions & 4 deletions src/api/integrations/typebot/services/typebot.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -719,10 +719,13 @@ export class TypebotService {
listResponseMessage: msg?.message?.listResponseMessage?.singleSelectReply?.selectedRowId,
responseRowId: msg?.message?.listResponseMessage?.singleSelectReply?.selectedRowId,
// Medias
audioMessage: `audioMessage:${msg?.key?.id}`,
imageMessage: `imageMessage:${msg?.key?.id}`,
videoMessage: `videoMessage:${msg?.key?.id}`,
documentMessage: `documentMessage:${msg?.key?.id}`,
audioMessage: msg?.message?.audioMessage ? `audioMessage:${msg?.key?.id}` : undefined,
imageMessage: msg?.message?.imageMessage ? `imageMessage:${msg?.key?.id}` : undefined,
videoMessage: msg?.message?.videoMessage ? `videoMessage:${msg?.key?.id}` : undefined,
documentMessage: msg?.message?.documentMessage ? `documentMessage:${msg?.key?.id}` : undefined,
documentWithCaptionMessage: msg?.message?.auddocumentWithCaptionMessageioMessage
? `documentWithCaptionMessage:${msg?.key?.id}`
: undefined,
};

const messageType = Object.keys(types).find((key) => types[key] !== undefined) || 'unknown';
Expand Down
8 changes: 4 additions & 4 deletions src/api/services/channels/whatsapp.baileys.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,10 @@ export class BaileysStartupService extends ChannelStartupService {

this.sendDataWebhook(Events.MESSAGES_UPSERT, messageRaw);

await this.prismaRepository.message.create({
data: messageRaw,
});

if (
this.configService.get<Chatwoot>('CHATWOOT').ENABLED &&
this.localChatwoot.enabled &&
Expand Down Expand Up @@ -1202,10 +1206,6 @@ export class BaileysStartupService extends ChannelStartupService {
}
}

await this.prismaRepository.message.create({
data: messageRaw,
});

const contact = await this.prismaRepository.contact.findFirst({
where: { remoteJid: received.key.remoteJid, instanceId: this.instanceId },
});
Expand Down

0 comments on commit a8937bd

Please sign in to comment.