Class: Mail2cb::MessageIdHandler
- Inherits:
-
Object
- Object
- Mail2cb::MessageIdHandler
- Defined in:
- lib/mail2cb/message_id_handler.rb
Instance Method Summary collapse
- #from_body ⇒ Object
- #from_headers ⇒ Object
- #from_subject ⇒ Object
- #hash ⇒ Object
-
#initialize(email) ⇒ MessageIdHandler
constructor
A new instance of MessageIdHandler.
- #message_id ⇒ Object
- #references ⇒ Object
Constructor Details
#initialize(email) ⇒ MessageIdHandler
Returns a new instance of MessageIdHandler.
4 5 6 7 8 |
# File 'lib/mail2cb/message_id_handler.rb', line 4 def initialize(email) @email = email @content = EmailContent.new(@email) end |
Instance Method Details
#from_body ⇒ Object
37 38 39 |
# File 'lib/mail2cb/message_id_handler.rb', line 37 def from_body find_in_content(@content.html) || find_in_content(@content.text) end |
#from_headers ⇒ Object
31 32 33 |
# File 'lib/mail2cb/message_id_handler.rb', line 31 def from_headers references.reverse.detect{|id| find_in_content(id) } end |
#from_subject ⇒ Object
34 35 36 |
# File 'lib/mail2cb/message_id_handler.rb', line 34 def from_subject find_in_content(@email.subject) end |
#hash ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/mail2cb/message_id_handler.rb', line 14 def hash if match = /([a-z]*?)\.([a-z0-9]*?)\.([a-z0-9]*?)@mail.caseblocks.com/.match() if match if match[1] == "conversation" {"conversation_id" => match[2]} elsif match[1] == "case" {"case_id" => match[2]} else {match[1] => match[2]} end end else {} end end |
#message_id ⇒ Object
10 11 12 |
# File 'lib/mail2cb/message_id_handler.rb', line 10 def from_headers || from_subject || from_body end |
#references ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/mail2cb/message_id_handler.rb', line 40 def references refs = @email.header["References"] begin if refs && refs.field.errors.empty? return refs.field.element. end rescue ap @email.header["References"] end [] end |