Class: Office::EmailMessage
- Inherits:
-
Object
- Object
- Office::EmailMessage
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- lib/office/email_message.rb
Overview
When I receive one.
Instance Method Summary collapse
- #apply_filter(filter) ⇒ Object
- #conv ⇒ Object
- #lead ⇒ Object
-
#object_key ⇒ Object
aka ‘filename’, use with bucket name + prefix.
- #preview_str ⇒ Object
- #received_at ⇒ Object
Instance Method Details
#apply_filter(filter) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/office/email_message.rb', line 64 def apply_filter filter case filter.kind when ::Office::EmailFilter::KIND_DESTROY_SCHS conv.add_tag ::WpTag::TRASH conv.remove_tag ::WpTag::INBOX lead.schs.each do |sch| sch.update_attributes({ state: ::Sch::STATE_TRASH }) end when ::Office::EmailFilter::KIND_ADD_TAG conv.add_tag filter.wp_term_id if ::WpTag::TRASH == ::WpTag.find( filter.wp_term_id ).slug conv.remove_tag ::WpTag::INBOX end when ::Office::EmailFilter::KIND_REMOVE_TAG conv.remove_tag filter.wp_term_id when ::Office::EmailFilter::KIND_AUTORESPOND_TMPL Ish::EmailContext.create({ email_template: filter.email_template, lead_id: lead.id, send_at: Time.now + 22.minutes, }) when ::Office::EmailFilter::KIND_AUTORESPOND_EACT ::Sch.create({ email_action: filter.email_action, state: ::Sch::STATE_ACTIVE, lead_id: lead.id, perform_at: Time.now + 22.minutes, }) else raise "unknown filter kind: #{filter.kind}" end end |
#conv ⇒ Object
50 51 52 |
# File 'lib/office/email_message.rb', line 50 def conv email_conversation end |
#lead ⇒ Object
31 32 33 |
# File 'lib/office/email_message.rb', line 31 def lead Lead.find_by email: from end |
#object_key ⇒ Object
aka ‘filename’, use with bucket name + prefix. I need this!
19 |
# File 'lib/office/email_message.rb', line 19 field :object_key, type: :string |
#preview_str ⇒ Object
56 57 58 59 60 61 |
# File 'lib/office/email_message.rb', line 56 def preview_str body = part_html || part_html || 'Neither part_html nor part_txt!' body = ::ActionView::Base.full_sanitizer.sanitize( body ).gsub(/\s+/, ' ') body = body[0..200] body end |
#received_at ⇒ Object
45 46 47 |
# File 'lib/office/email_message.rb', line 45 def received_at date end |