griddler 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f86495d4d8db4365d3cb48c7cb3270aab9b23bb
4
- data.tar.gz: c4765e837d4102415a3b980503146b6644806126
3
+ metadata.gz: 033ea4e395dad81582d32273bb841a0fc8cf00b2
4
+ data.tar.gz: da3e0f317134724e14dbe362de41882f121ebfdb
5
5
  SHA512:
6
- metadata.gz: 7ab5c192b77282a442a0f1bd0f6a1b386687c694ad68f7eeeeb36d3a7b940e318c43375a64765c9ac4574d1ffe60ce3ab2937dcee262cac297cd85eaee7f9c2e
7
- data.tar.gz: 98caf933840397cff2dcd5900cb4961e975e10c92f75f91d3c7b9d179bccf8a314e6f17ff8e5cdc6f26b43b6143a02dc2c7d028c6dc20f81b02d17b4fcb3e447
6
+ metadata.gz: 753dddc90229903fa836cd31790164431603d3feda2dfa81b1e0a0cd17dc8f2e3428f09ed8fe210a4f54c5ca8e464dc85c86e1fbb5cdfa4f19abd73612a79738
7
+ data.tar.gz: ab5c5cea2b4d84bfed1e764f5a807bb847c9550c6b604d0ff1d71d33bfeb7df476b79c5500b985d25ccadd50091481c1be7132ee2c14a4c0d0a2f0f298f07acf
data/README.md CHANGED
@@ -65,7 +65,7 @@ end
65
65
  | `processor_class` | The class Griddler will use to handle your incoming emails.
66
66
  | `email_class` | The class Griddler will use to represent an incoming e-mail. It must support an initializer that receives a hash as the only argument. We recommend inheriting it from Griddler::Email or checking this class to see all the methods it responds to.
67
67
  | `processor_method` | The method Griddler will call on the processor class when handling your incoming emails.
68
- | `reply_delimiter` | The string searched for that will split your body.
68
+ | `reply_delimiter` | The string searched for that will split your body. You can also supply an array of string - useful if you need translated versions of the delimiter
69
69
  | `email_service` | Tells Griddler which email service you are using. The supported email service options are `:sendgrid` (the default), `:cloudmailin` (expects multipart format), `:postmark`, `:mandrill` and `:mailgun`. You will also need to have an appropriate [adapter] gem included in your Gemfile.
70
70
 
71
71
  By default Griddler will look for a class named `EmailProcessor`. The class is
@@ -168,6 +168,7 @@ adapter gem in addition to `griddler`.
168
168
  | Service | Adapter
169
169
  | ------- | -------
170
170
  | sendgrid | [griddler-sendgrid]
171
+ | cloudmailin | [griddler-cloudmailin]
171
172
  | mandrill | [griddler-mandrill]
172
173
  | mailgun | [griddler-mailgun]
173
174
  | postmark | [griddler-postmark]
@@ -175,6 +176,7 @@ adapter gem in addition to `griddler`.
175
176
  | ses (amazon)| [griddler-ses]
176
177
 
177
178
  [griddler-sendgrid]: https://github.com/thoughtbot/griddler-sendgrid
179
+ [griddler-cloudmailin]: https://github.com/thoughtbot/griddler-cloudmailin
178
180
  [griddler-mandrill]: https://github.com/wingrunr21/griddler-mandrill
179
181
  [griddler-mailgun]: https://github.com/bradpauly/griddler-mailgun
180
182
  [griddler-postmark]: https://github.com/r38y/griddler-postmark
@@ -215,6 +217,6 @@ Griddler was written by Caleb Thompson and Joel Oliveira.
215
217
 
216
218
  Thanks to our [contributors](https://github.com/thoughtbot/griddler/contributors)!
217
219
 
218
- ![thoughtbot](http://thoughtbot.com/images/tm/logo.png)
220
+ ![thoughtbot](http://presskit.thoughtbot.com/images/thoughtbot-logo-for-readmes.svg)
219
221
 
220
222
  The names and logos for thoughtbot are trademarks of thoughtbot, inc.
@@ -1,4 +1,6 @@
1
1
  class Griddler::EmailsController < ActionController::Base
2
+ skip_before_action :verify_authenticity_token
3
+
2
4
  def create
3
5
  normalized_params.each do |p|
4
6
  process_email email_class.new(p)
@@ -3,8 +3,23 @@ require 'htmlentities'
3
3
  module Griddler
4
4
  class Email
5
5
  include ActionView::Helpers::SanitizeHelper
6
- attr_reader :to, :from, :cc, :bcc, :subject, :body, :raw_body, :raw_text, :raw_html,
7
- :headers, :raw_headers, :attachments
6
+
7
+ attr_reader :to,
8
+ :from,
9
+ :cc,
10
+ :bcc,
11
+ :original_recipient,
12
+ :reply_to,
13
+ :subject,
14
+ :body,
15
+ :raw_body,
16
+ :raw_text,
17
+ :raw_html,
18
+ :headers,
19
+ :raw_headers,
20
+ :attachments,
21
+ :vendor_specific,
22
+ :spam_report
8
23
 
9
24
  def initialize(params)
10
25
  @params = params
@@ -22,10 +37,16 @@ module Griddler
22
37
 
23
38
  @cc = recipients(:cc)
24
39
  @bcc = recipients(:bcc)
40
+ @original_recipient = extract_address(params[:original_recipient])
41
+ @reply_to = extract_address(params[:reply_to])
25
42
 
26
43
  @raw_headers = params[:headers]
27
44
 
28
45
  @attachments = params[:attachments]
46
+
47
+ @vendor_specific = params.fetch(:vendor_specific, {})
48
+
49
+ @spam_report = params[:spam_report]
29
50
  end
30
51
 
31
52
  def to_h
@@ -42,9 +63,16 @@ module Griddler
42
63
  headers: headers,
43
64
  raw_headers: raw_headers,
44
65
  attachments: attachments,
66
+ vendor_specific: vendor_specific,
67
+ spam_score: spam_score,
68
+ spam_report: spam_report,
45
69
  }
46
70
  end
47
71
 
72
+ def spam_score
73
+ @spam_report[:score] if @spam_report
74
+ end
75
+
48
76
  private
49
77
 
50
78
  attr_reader :params
@@ -84,7 +84,10 @@ module Griddler::EmailParser
84
84
  /^On.*<\r?\n?.*>.*\r?\n?wrote:\r?\n?$/,
85
85
  /On.*wrote:/,
86
86
  /\*?From:.*$/i,
87
- /^[[:space:]]*\d{4}[-\/]\d{1,2}[-\/]\d{1,2}[[:space:]].*[[:space:]]<.*>?$/i
87
+ /^[[:space:]]*\d{4}[-\/]\d{1,2}[-\/]\d{1,2}[[:space:]].*[[:space:]]<.*>?$/i,
88
+ /(_)*\n[[:space:]]*De :.*\n[[:space:]]*Envoyé :.*\n[[:space:]]*À :.*\n[[:space:]]*Objet :.*\n$/i, # French Outlook
89
+ /^[[:space:]]*\>?[[:space:]]*Le.*<\n?.*>.*\n?a[[:space:]]?\n?écrit :$/, # French
90
+ /^[[:space:]]*\>?[[:space:]]*El.*<\n?.*>.*\n?escribió:$/ # Spanish
88
91
  ]
89
92
  end
90
93
 
@@ -1,3 +1,3 @@
1
1
  module Griddler
2
- VERSION = '1.4.0'
2
+ VERSION = '1.5.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: griddler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caleb Thompson
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2017-02-27 00:00:00.000000000 Z
14
+ date: 2018-04-23 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
@@ -122,7 +122,8 @@ files:
122
122
  - lib/griddler/testing.rb
123
123
  - lib/griddler/version.rb
124
124
  homepage: http://thoughtbot.com
125
- licenses: []
125
+ licenses:
126
+ - MIT
126
127
  metadata: {}
127
128
  post_install_message:
128
129
  rdoc_options: []