Sha256: 14c8585fa2c55a1529cc8c88fcb0ab0c0d8c162dc363c18f7ed29d6abf321796
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
module Replyr class ReplyEmail attr_accessor :to, :from, :subject, :body, :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 files # can later be processed by e.g. carrierwave # self.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.handle_reply(reply_address.user, stripped_body, files) true else false end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
replyr-0.0.7 | lib/replyr/reply_email.rb |