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
@TODO: move to email_conversation vp 2023-03-24.
- #company_url ⇒ Object
- #conv ⇒ Object
-
#lead ⇒ Object
attachments ?.
-
#name ⇒ Object
@TODO: reimplement.
-
#object_key ⇒ Object
aka ‘filename’, use with bucket name + prefix.
- #received_at ⇒ Object
- #remove_tag(tag) ⇒ Object
- #rmtag(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
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/office/email_message.rb', line 46 def add_tag tag case tag.class.name when 'WpTag' ; when 'String' tag = WpTag.emailtag(tag) else throw "#add_tag2 expects a WpTag or string (eg WpTag::INBOX) as the only parameter." end self[:wp_term_ids] = ( [ tag.id ] + self[:wp_term_ids] ).uniq self.save! end |
#apply_filter(filter) ⇒ Object
@TODO: move to email_conversation vp 2023-03-24
89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/office/email_message.rb', line 89 def apply_filter filter case filter.kind when ::Office::EmailFilter::KIND_SKIP_INBOX self.remove_tag( WpTag::INBOX ) self.conv.remove_tag( WpTag::INBOX ) when ::Office::EmailFilter::KIND_AUTORESPOND 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
84 85 86 |
# File 'lib/office/email_message.rb', line 84 def company_url from[0].split('@')[1] end |
#conv ⇒ Object
74 75 76 |
# File 'lib/office/email_message.rb', line 74 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
79 80 81 82 |
# File 'lib/office/email_message.rb', line 79 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
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/office/email_message.rb', line 58 def remove_tag tag case tag.class.name when 'WpTag' ; when 'String' tag = WpTag.emailtag(tag) else throw "#remove_tag2 expects a WpTag or string (eg WpTag::INBOX) as the only parameter." end self[:wp_term_ids] = self[:wp_term_ids] - [ tag.id ] out = self.save! out end |
#rmtag(tag) ⇒ Object
71 |
# File 'lib/office/email_message.rb', line 71 def rmtag tag; remove_tag tag; 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: [] |