incoming 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/incoming.rb +1 -1
- data/lib/incoming/strategies/postmark.rb +36 -9
- data/lib/incoming/strategy.rb +1 -1
- metadata +19 -35
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1342785e330570e8dead5676e9f6bfbbfc5e7c71
|
4
|
+
data.tar.gz: 131181e9b82a02b6fa5532cd57d1a00c1e77382a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bedd0840a7fd2cb6ac7fa8e8f8737b041f4e8ee2cd320fa84225ce7a16c08b1ce2f614a2a18e1429785c97a121f263ad75dd54da7738b3c3fa24c01fe5220122
|
7
|
+
data.tar.gz: cab1511a00c240863aabef46d66d721393b168d4b4316350f481c02eeb803bcb172072f5f45f12033f694ca9116c21e47ef45d7e2baf12009991135b9e6c1003
|
data/lib/incoming.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'json'
|
2
2
|
require 'base64'
|
3
3
|
|
4
4
|
module Incoming
|
@@ -7,25 +7,52 @@ module Incoming
|
|
7
7
|
include Incoming::Strategy
|
8
8
|
|
9
9
|
def initialize(request)
|
10
|
-
|
10
|
+
source = JSON.parse(request.body.read)
|
11
11
|
|
12
|
-
|
12
|
+
headers = parse_headers(source['Headers'])
|
13
|
+
from = parse_address(source['FromFull'])
|
14
|
+
to = source['ToFull'].map{|h| parse_address(h)}
|
15
|
+
cc = source['CcFull'].map{|h| parse_address(h)}
|
13
16
|
|
14
17
|
@message = Mail.new do
|
15
|
-
headers
|
18
|
+
headers headers
|
19
|
+
from from
|
20
|
+
to to
|
21
|
+
cc cc
|
22
|
+
reply_to source['ReplyTo']
|
23
|
+
subject source['Subject']
|
24
|
+
date source['Date']
|
16
25
|
|
17
|
-
body
|
26
|
+
body source['TextBody']
|
18
27
|
|
19
28
|
html_part do
|
20
29
|
content_type 'text/html; charset=UTF-8'
|
21
|
-
body
|
22
|
-
end if
|
30
|
+
body CGI.unescapeHTML(source['HtmlBody'])
|
31
|
+
end if source['HtmlBody']
|
23
32
|
|
24
|
-
|
25
|
-
add_file :filename => a
|
33
|
+
source['Attachments'].each do |a|
|
34
|
+
add_file :filename => a['Name'], :content => Base64.decode64(a['Content'])
|
35
|
+
end
|
36
|
+
|
37
|
+
%w(MailboxHash MessageID Tag).each do |key|
|
38
|
+
if source[key] =~ /\S/
|
39
|
+
header[key] = source[key]
|
40
|
+
end
|
26
41
|
end
|
27
42
|
end
|
28
43
|
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def parse_headers(source)
|
48
|
+
source.inject({}){|hash,obj| hash[obj['Name']] = obj['Value']; hash}
|
49
|
+
end
|
50
|
+
|
51
|
+
def parse_address(hash)
|
52
|
+
Mail::Address.new(hash['Email']).tap do |address|
|
53
|
+
address.display_name = hash['Name']
|
54
|
+
end.to_s
|
55
|
+
end
|
29
56
|
end
|
30
57
|
end
|
31
58
|
end
|
data/lib/incoming/strategy.rb
CHANGED
@@ -111,7 +111,7 @@ module Incoming
|
|
111
111
|
# Returns Hash for Mail::Message#add_file
|
112
112
|
def attachment_from_params(uploaded_file_or_hash)
|
113
113
|
filename, content = if Hash === uploaded_file_or_hash
|
114
|
-
[uploaded_file_or_hash[
|
114
|
+
[uploaded_file_or_hash[:filename], uploaded_file_or_hash[:tempfile].read]
|
115
115
|
else
|
116
116
|
[uploaded_file_or_hash.original_filename, uploaded_file_or_hash.read]
|
117
117
|
end
|
metadata
CHANGED
@@ -1,78 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: incoming
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.6
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Joshua Wood
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-12-27 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
14
|
+
name: rack
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
19
|
+
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
26
|
+
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
28
|
+
name: mail
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
33
|
+
version: '2.4'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
40
|
+
version: '2.4'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rake
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rspec
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - '>='
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - '>='
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
description: Incoming! standardizes various mail parse apis, making it a snap to receive
|
@@ -97,32 +88,25 @@ files:
|
|
97
88
|
- bin/http_post
|
98
89
|
homepage: https://github.com/honeybadger-io/incoming
|
99
90
|
licenses: []
|
91
|
+
metadata: {}
|
100
92
|
post_install_message:
|
101
93
|
rdoc_options: []
|
102
94
|
require_paths:
|
103
95
|
- lib
|
104
96
|
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
97
|
requirements:
|
107
|
-
- -
|
98
|
+
- - '>='
|
108
99
|
- !ruby/object:Gem::Version
|
109
100
|
version: '0'
|
110
|
-
segments:
|
111
|
-
- 0
|
112
|
-
hash: 1004414202407084554
|
113
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
-
none: false
|
115
102
|
requirements:
|
116
|
-
- -
|
103
|
+
- - '>='
|
117
104
|
- !ruby/object:Gem::Version
|
118
105
|
version: '0'
|
119
|
-
segments:
|
120
|
-
- 0
|
121
|
-
hash: 1004414202407084554
|
122
106
|
requirements: []
|
123
107
|
rubyforge_project:
|
124
|
-
rubygems_version: 1.
|
108
|
+
rubygems_version: 2.1.5
|
125
109
|
signing_key:
|
126
|
-
specification_version:
|
110
|
+
specification_version: 4
|
127
111
|
summary: Incoming! helps you receive email in your Rack apps.
|
128
112
|
test_files: []
|