diff --git a/app/builders/messages/forwarded_message_builder.rb b/app/builders/messages/forwarded_message_builder.rb index cb45824ca..c1afc976e 100644 --- a/app/builders/messages/forwarded_message_builder.rb +++ b/app/builders/messages/forwarded_message_builder.rb @@ -42,9 +42,16 @@ class Messages::ForwardedMessageBuilder 'full' => full_content }) + # Copy over any attachment data if present + data['attachments'] = forwarded_message.attachments.map(&:serializable_hash) if forwarded_message.attachments.present? + data end + def forwarded_attachments + forwarded_message.attachments if forwarded_message&.attachments&.present? + end + private def valid_forwarded_data? diff --git a/app/builders/messages/message_builder.rb b/app/builders/messages/message_builder.rb index c0ef6803b..227e39691 100644 --- a/app/builders/messages/message_builder.rb +++ b/app/builders/messages/message_builder.rb @@ -16,6 +16,7 @@ class Messages::MessageBuilder process_forwarded_message if @forwarded_message_id.present? @message = @conversation.messages.build(message_params) process_attachments + process_forwarded_attachments if @forwarded_message_id.present? process_emails @message.save! @message @@ -26,6 +27,7 @@ class Messages::MessageBuilder def process_forwarded_message builder = Messages::ForwardedMessageBuilder.new(@forwarded_message_id) @forwarded_attributes = builder.perform + @forwarded_message_attachments = builder.forwarded_attachments # Update content to include forwarded message original_content = @params[:content_original] || @params[:content] @@ -38,6 +40,28 @@ class Messages::MessageBuilder @forwarded_attributes[:content_attributes][:email] = builder.forwarded_email_data(original_content) end + # Process attachments from the forwarded message + def process_forwarded_attachments + return if @forwarded_message_attachments.blank? + + @forwarded_message_attachments.each do |source_attachment| + # Create a new attachment for the current message + attachment = @message.attachments.build( + account_id: @message.account_id, + file_type: source_attachment.file_type + ) + + # Attach the file by directly copying it from the source attachment + next unless source_attachment.file.attached? + + attachment.file.attach( + io: StringIO.new(source_attachment.file.download), + filename: source_attachment.file.filename.to_s, + content_type: source_attachment.file.content_type + ) + end + end + # Extracts content attributes from the given params. # - Converts ActionController::Parameters to a regular hash if needed. # - Attempts to parse a JSON string if content is a string. diff --git a/app/javascript/dashboard/components-next/message/bubbles/Email/EmailMeta.vue b/app/javascript/dashboard/components-next/message/bubbles/Email/EmailMeta.vue index 0c0f04a7e..2f1d014b8 100644 --- a/app/javascript/dashboard/components-next/message/bubbles/Email/EmailMeta.vue +++ b/app/javascript/dashboard/components-next/message/bubbles/Email/EmailMeta.vue @@ -69,10 +69,7 @@ const showMeta = computed(() => { v-show="showMeta" :class="hasError ? 'text-n-ruby-11' : 'text-n-slate-11'" > -