griddler-ses 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/griddler/ses/adapter.rb +5 -16
- data/lib/griddler/ses/middleware.rb +25 -0
- data/lib/griddler/ses/railtie.rb +9 -0
- data/lib/griddler/ses/version.rb +1 -1
- data/lib/griddler/ses.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a254412f4d73e3ca99782daa1c8f067cbf916f99
|
4
|
+
data.tar.gz: cf45a3a5826cf3954b21dfe3adf6ca31eba93517
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b78e58bd0a0541c9fb4111a53beaed53747281a9cb0de2cab6f4e2241cc95f3196f9ff2b1e2871202391addd6441b4c542f1c417756774e1fd7e8da4badf19b8
|
7
|
+
data.tar.gz: 3945b1b7c8f13796a06fd15d3b27963379b781bd57e4ae357f9d2a49e86fc76e4ce7eea31c26b273f02c01d5468de8c07a5b42864b894af6c375d9f08918e889
|
data/lib/griddler/ses/adapter.rb
CHANGED
@@ -5,15 +5,14 @@ require 'net/http'
|
|
5
5
|
module Griddler
|
6
6
|
module Ses
|
7
7
|
class Adapter
|
8
|
-
attr_reader :
|
8
|
+
attr_reader :sns_json
|
9
9
|
|
10
|
-
def initialize(params
|
11
|
-
@
|
12
|
-
@raw_request = raw_request
|
10
|
+
def initialize(params)
|
11
|
+
@sns_json = params
|
13
12
|
end
|
14
13
|
|
15
14
|
def self.normalize_params(params)
|
16
|
-
adapter = new(params
|
15
|
+
adapter = new(params)
|
17
16
|
adapter.normalize_params
|
18
17
|
end
|
19
18
|
|
@@ -29,7 +28,7 @@ module Griddler
|
|
29
28
|
{}
|
30
29
|
when :Notification
|
31
30
|
ensure_valid_notification_type!
|
32
|
-
|
31
|
+
sns_json.merge(
|
33
32
|
to: recipients,
|
34
33
|
from: sender,
|
35
34
|
cc: cc,
|
@@ -46,10 +45,6 @@ module Griddler
|
|
46
45
|
end
|
47
46
|
|
48
47
|
private
|
49
|
-
def sns_json
|
50
|
-
@sns_json ||= JSON.parse(raw_request.raw_post)
|
51
|
-
end
|
52
|
-
|
53
48
|
def email_json
|
54
49
|
@email_json ||= JSON.parse(sns_json['Message'])
|
55
50
|
end
|
@@ -135,12 +130,6 @@ module Griddler
|
|
135
130
|
confirmation_endpoint = URI.parse(sns_json['SubscribeURL'])
|
136
131
|
Net::HTTP.get confirmation_endpoint
|
137
132
|
end
|
138
|
-
|
139
|
-
def self.raw_request
|
140
|
-
# TODO: this is an ugly hack using introspection to get the request from the calling controller; should update Griddler
|
141
|
-
# to provide the full request context
|
142
|
-
raw_request = binding.of_caller(2).eval('request')
|
143
|
-
end
|
144
133
|
end
|
145
134
|
end
|
146
135
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Griddler
|
2
|
+
module Ses
|
3
|
+
class Middleware
|
4
|
+
def initialize(app)
|
5
|
+
@app = app
|
6
|
+
end
|
7
|
+
|
8
|
+
def call(env)
|
9
|
+
# a bug on the AWS side doesn't set the content type to application/json type properly,
|
10
|
+
# so we have to intercept and do this in order for Griddler's controller to correctly
|
11
|
+
# parse the parameters (see https://forums.aws.amazon.com/thread.jspa?messageID=418160)
|
12
|
+
if env['REQUEST_PATH'] == griddler_path
|
13
|
+
env['CONTENT_TYPE'] = 'application/json; charset=UTF-8'
|
14
|
+
end
|
15
|
+
|
16
|
+
@app.call(env)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def griddler_path
|
21
|
+
@griddler_path ||= Rails.application.routes.url_helpers.url_for(controller: 'griddler/emails', action: 'create', only_path: true)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/griddler/ses/version.rb
CHANGED
data/lib/griddler/ses.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: griddler-ses
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kent Mewhort @ Coupa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: griddler
|
@@ -111,6 +111,8 @@ files:
|
|
111
111
|
- griddler-ses.gemspec
|
112
112
|
- lib/griddler/ses.rb
|
113
113
|
- lib/griddler/ses/adapter.rb
|
114
|
+
- lib/griddler/ses/middleware.rb
|
115
|
+
- lib/griddler/ses/railtie.rb
|
114
116
|
- lib/griddler/ses/version.rb
|
115
117
|
homepage: https://github.com/85x14/griddler-ses
|
116
118
|
licenses:
|