Sha256: 0607f2b3806fd32b48946428a896f47cf3d97a76fc5c0a78a17f58bbb81e9878
Contents?: true
Size: 1.34 KB
Versions: 2
Compression:
Stored size: 1.34 KB
Contents
module Replyr class ReplyEmail attr_accessor :to, :from, :subject, :body, :attached_files def initialize(mail) self.to = mail.to.first self.from = mail.from.first self.subject = mail.subject self.body = mail.multipart? ? mail.text_part.decoded : mail.decoded # Extract Attachments and store as StringIO in attached_files # can later be processed by e.g. carrierwave # self.attached_files = mail.attachments.map 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 end def self.process(mail) reply_mail = new(mail) reply_mail.process end # Checks if this incoming mail is a reply email # def is_reply_email? to.starts_with?(Replyr.config.prefix) end def stripped_body EmailReplyParser.parse_reply(body, from).to_s.force_encoding("UTF-8") end def process if is_reply_email? if reply_address = ReplyAddress.new_from_address(to) reply_address.model.class.handle_reply(reply_token, stripped_body, attached_files) else # no valid reply_address end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
replyr-0.0.5 | lib/replyr/reply_email.rb |
replyr-0.0.4 | lib/replyr/reply_email.rb |