Skip to content

Commit

Permalink
Merge pull request #753 from raimartinsb/develop
Browse files Browse the repository at this point in the history
fix: Correction of media as attachments in chatwoot when using a Meta API Instance and not Baileys
  • Loading branch information
DavidsonGomes authored Aug 12, 2024
2 parents 293f6a3 + 91f009a commit ebd70fe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/api/integrations/chatwoot/services/chatwoot.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,6 @@ export class ChatwootService {
findByName = inbox.payload.find((inbox) => inbox.name === this.getClientCwConfig().name_inbox.split('-cwId-')[0]);
}


if (!findByName) {
this.logger.warn('inbox not found');
return null;
Expand Down Expand Up @@ -1907,7 +1906,8 @@ export class ChatwootService {

let nameFile: string;
const messageBody = body?.message[body?.messageType];
const originalFilename = messageBody?.fileName || messageBody?.message?.documentMessage?.fileName;
const originalFilename =
messageBody?.fileName || messageBody?.filename || messageBody?.message?.documentMessage?.fileName;
if (originalFilename) {
const parsedFile = path.parse(originalFilename);
if (parsedFile.name && parsedFile.ext) {
Expand Down
3 changes: 2 additions & 1 deletion src/api/services/channels/whatsapp.business.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,7 @@ export class BusinessStartupService extends ChannelStartupService {
[message['type']]: message['id'],
preview_url: linkPreview,
caption: message['caption'],
filename: message['fileName'],
},
};
quoted ? (content.context = { message_id: quoted.id }) : content;
Expand Down Expand Up @@ -1212,7 +1213,7 @@ export class BusinessStartupService extends ChannelStartupService {
try {
const msg = data.message;
this.logger.verbose('Getting base64 from media message');
const messageType = msg.messageType + 'Message';
const messageType = msg.messageType.includes('Message') ? msg.messageType : msg.messageType + 'Message';
const mediaMessage = msg.message[messageType];

this.logger.verbose('Media message downloaded');
Expand Down

0 comments on commit ebd70fe

Please sign in to comment.