Skip to content
This repository was archived by the owner on Jul 12, 2024. It is now read-only.

Commit c4b3c39

Browse files
matthewbarramgabebw
authored andcommitted
Not forcing processing on hashes
1 parent fed6658 commit c4b3c39

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Griddler::Email attributes
105105
| `#raw_html` | The raw html part of the body.
106106
| `#raw_body` | The raw body information provided by the email service.
107107
| `#attachments` | An array of `File` objects containing any attachments.
108-
| `#headers` | A hash of headers parsed by `Mail::Header`.
108+
| `#headers` | A hash of headers parsed by `Mail::Header`, unless they are already formatted as a hash when received from the adapter in which case the original hash is returned.
109109
| `#raw_headers` | The raw headers included in the message.
110110

111111
### Email Addresses

lib/griddler/email_parser.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ def self.extract_reply_body(body)
4040
end
4141

4242
def self.extract_headers(raw_headers)
43+
if raw_headers.is_a?(Hash)
44+
return raw_headers
45+
end
4346
header_fields = Mail::Header.new(raw_headers).fields
4447

4548
header_fields.inject({}) do |header_hash, header_field|

spec/griddler/email_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,15 @@ def email_with_params(params)
458458
expect(headers[header_name]).to eq header_value
459459
end
460460

461+
it 'handles a hash being submitted' do
462+
header = {
463+
"X-Mailer" => "Airmail (271)",
464+
"Mime-Version" => "1.0"
465+
}
466+
headers = header_from_email(header)
467+
expect(headers["X-Mailer"]).to eq("Airmail (271)")
468+
end
469+
461470
it 'handles no matched headers' do
462471
headers = header_from_email('')
463472
expect(headers).to eq({})

0 commit comments

Comments
 (0)