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
-
#add_tag(tag) ⇒ Object
Tested manually ok, does not pass the spec.
- #apply_filter(filter) ⇒ Object
- #company_url ⇒ Object
- #conv ⇒ Object
-
#lead ⇒ Object
attachments ?.
-
#name ⇒ Object
@TODO: reimplement, look at footer instead.
-
#object_key ⇒ Object
aka ‘filename’, use with bucket name + prefix.
- #received_at ⇒ Object
- #remove_tag(tag) ⇒ Object
-
#wp_term_ids ⇒ Object
Copied to email_conversation.
Instance Method Details
#add_tag(tag) ⇒ Object
Tested manually ok, does not pass the spec. @TODO: hire to make pass spec? vp 2023-03-07
45 46 47 48 49 50 51 52 |
# File 'lib/office/email_message.rb', line 45 def add_tag tag if WpTag == tag.class self[:wp_term_ids] = self[:wp_term_ids].push(tag.id).uniq self.save! else throw "#add_tag expects a WpTag as the only parameter." end end |
#apply_filter(filter) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/office/email_message.rb', line 77 def apply_filter filter case filter.kind when ::Office::EmailFilter::KIND_SKIP_INBOX self.remove_tag( ::WpTag.email_inbox_tag ) when ::Office::EmailFilter::KIND_AUTORESPOND Ish::EmailContext.create({ email_template: ::Tmpl.find_by_slug( filter.email_template_slug ), lead: lead, }) # when 'autorespond-remind' # Office::EmailAction.create({ # tmpl_slug: 'require-sign-nda', # next_in_days: -> { rand(1..5) }, # next_at_time: ->{ rand(8..16).hours + rand(1..59).minutes }, # next_action: 're-remind-sign-nda', # }) # Ish::EmailContext.create({ # email_template: ::Tmpl.find_by_slug( filter.email_template_slug ), # lead: lead, # }) else raise "unknown filter kind: #{filter.kind}" end end |
#company_url ⇒ Object
73 74 75 |
# File 'lib/office/email_message.rb', line 73 def company_url from[0].split('@')[1] end |
#conv ⇒ Object
63 64 65 |
# File 'lib/office/email_message.rb', line 63 def conv email_conversation end |
#lead ⇒ Object
attachments ?
26 27 28 |
# File 'lib/office/email_message.rb', line 26 def lead Lead.find_by email: from end |
#name ⇒ Object
@TODO: reimplement, look at footer instead.
68 69 70 71 |
# File 'lib/office/email_message.rb', line 68 def name return 'associate' # from[0].split('@')[0].upcase end |
#object_key ⇒ Object
aka ‘filename’, use with bucket name + prefix
17 |
# File 'lib/office/email_message.rb', line 17 field :object_key, type: :string |
#received_at ⇒ Object
38 39 40 |
# File 'lib/office/email_message.rb', line 38 def received_at date end |
#remove_tag(tag) ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/office/email_message.rb', line 53 def remove_tag tag if WpTag == tag.class self[:wp_term_ids].delete( tag.id ) self.save! else throw "#remove_tag expects a WpTag as the only parameter." end end |
#wp_term_ids ⇒ Object
Copied to email_conversation
43 |
# File 'lib/office/email_message.rb', line 43 field :wp_term_ids, type: Array, default: [] |