Skip to content
This repository has been archived by the owner on Jan 30, 2018. It is now read-only.

Fix broken processing of incoming email attachments #36

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
12 changes: 11 additions & 1 deletion app/models/emailer/incoming.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,17 @@ def process_incoming(email)
@body = strip_responses(@body).strip_tags.to_s.strip
@subject = email.subject.to_s.gsub(REPLY_REGEX, "").strip
@files = email.attachments || []


# Format attachments for processing by Paperclip
@files.collect! do |attachment|
file = StringIO.new(attachment.decoded)
file.class.class_eval { attr_accessor :original_filename, :content_type }
file.original_filename = attachment.filename
file.content_type = attachment.mime_type

file
end

Rails.logger.info "#{@user.name} <#{@user.email}> sent '#{@subject}' to #{@to}"
end

Expand Down