diff --git a/src/apps/chatwoot/consumers/utils.ts b/src/apps/chatwoot/consumers/utils.ts new file mode 100644 index 00000000..06219877 --- /dev/null +++ b/src/apps/chatwoot/consumers/utils.ts @@ -0,0 +1,13 @@ +export function clearContent(attachments) { + /** + * Remove actual base64 "content" from attachment + */ + if (!attachments) { + return attachments; + } + return attachments.map((attachment) => { + attachment = { ...attachment }; + attachment.content = ''; + return attachment; + }); +} diff --git a/src/apps/chatwoot/consumers/waha/base.ts b/src/apps/chatwoot/consumers/waha/base.ts index 9acef324..a666d5c1 100644 --- a/src/apps/chatwoot/consumers/waha/base.ts +++ b/src/apps/chatwoot/consumers/waha/base.ts @@ -39,6 +39,7 @@ import { ChatWootAppConfig, ChatWootConfig, } from '@waha/apps/chatwoot/dto/config.dto'; +import { clearContent } from '@waha/apps/chatwoot/consumers/utils'; export function ListenEventsForChatWoot(config: ChatWootConfig) { const events = [ @@ -329,6 +330,8 @@ export abstract class MessageBaseHandler< `Created message as '${message.message_type}' from WhatsApp: ${response.id}`, ); await this.saveMapping(response, payload); + // Clear attachments content to avoid saving it in the task result + message.attachments = clearContent(message.attachments); return message; }