mail2cb 0.0.13 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d2cba71197126aa98852f1e336207c4135ffb5e
4
- data.tar.gz: ea8bc136dd810fcf720091dfc05ed0ea0118a72f
3
+ metadata.gz: 6ecc4a4ad6f33f02e2bbd5fabfbfb8f283d19c02
4
+ data.tar.gz: c812bfa12479a9db51fa650f8ed1529900b2be4d
5
5
  SHA512:
6
- metadata.gz: 401608a23939fb8fda0fade16549d771e170502a61873e213fb9d737030a0b822f1bb414e1f7acd8463854db134ffae995cfe0feea64bff84d9ac1d30a22d38c
7
- data.tar.gz: 1fc92b60cc5a1057670c73cbc5e56cd58869e295154113fe5da545365aebdac7fb024b349a9b161d7571d66de307f9006649fee33812b03c9fba134e7999f1ac
6
+ metadata.gz: b7492e5e145cc24e168094019dc54a365cc60275f9c9c0060c98f22608c243418fb1465939e5bf3e73f4c2639715ce2a7cc6fe4ae773ba6455835ca3b01340ef
7
+ data.tar.gz: b847d311e75e3788ff3221d23a43675134f678f7fe29564bfd4564308e53fdf9b0ce7cf2c8e932159c063feb75c8c1282fa81fcb56b4c1a6a7d9385361efd166
data/Dockerfile CHANGED
@@ -34,4 +34,4 @@ RUN cd /var/www/mail2cb
34
34
  RUN bundle install
35
35
 
36
36
  EXPOSE 8016
37
- CMD bin/mail2cb
37
+ CMD bin/run
data/bin/mail2cb CHANGED
@@ -34,4 +34,8 @@ ENV["CRYPT_API_ENDPOINT"] = "http://localhost:8888/case_blocks/crypt" if ENV["CR
34
34
 
35
35
  ENV["DEBUG"] = "false"
36
36
 
37
+ ENV["AWS_ACCESS_KEY_ID"] = ENV["AWS_ACCESS_KEY"] if ENV["AWS_ACCESS_KEY_ID"].nil?
38
+ ENV["AWS_SECRET_ACCESS_KEY"] = ENV["AWS_SECRET_KEY"] if ENV["AWS_SECRET_ACCESS_KEY"].nil?
39
+ ENV["AWS_REGION"] = "us-east-1" if ENV["AWS_REGION"].nil?
40
+
37
41
  oh = Mail2cb::Handler.new
data/bin/run CHANGED
@@ -33,4 +33,9 @@ ENV["FAYE_PORT"] = "9292"
33
33
 
34
34
  ENV["DEBUG"] = "false"
35
35
 
36
+ ENV["AWS_ACCESS_KEY_ID"] = ENV["AWS_ACCESS_KEY"] if ENV["AWS_ACCESS_KEY_ID"].nil?
37
+ ENV["AWS_SECRET_ACCESS_KEY"] = ENV["AWS_SECRET_KEY"] if ENV["AWS_SECRET_ACCESS_KEY"].nil?
38
+ ENV["AWS_REGION"] = "us-east-1" if ENV["AWS_REGION"].nil?
39
+
40
+
36
41
  oh = Mail2cb::Handler.new
@@ -2,7 +2,7 @@ require 'fileutils'
2
2
  require 'mail'
3
3
  require 'nokogiri'
4
4
  require 'sanitize'
5
- require 'aws/s3'
5
+ require 'aws-sdk'
6
6
 
7
7
  include Mail::Utilities
8
8
 
@@ -67,22 +67,24 @@ module Mail2cb
67
67
 
68
68
  def prepare_attachments
69
69
  attachments = []
70
- if ENV["AWS_ACCESS_KEY"] && ENV["AWS_SECRET_KEY"] && ENV["AWS_MAILROOM_BUCKET"]
71
- AWS::S3::Base.establish_connection!(
72
- :access_key_id => ENV["AWS_ACCESS_KEY"],
73
- :secret_access_key => ENV["AWS_SECRET_KEY"]
74
- )
70
+ if ENV["AWS_ACCESS_KEY_ID"] && ENV["AWS_SECRET_ACCESS_KEY"] && ENV["AWS_REGION"] && ENV["AWS_MAILROOM_BUCKET"]
75
71
  @email.attachments.each do |attachment|
76
72
  filename = attachment.filename
77
73
  bucket_name = ENV["AWS_MAILROOM_BUCKET"]
78
- path = ["", "attachments", @options[:mailbox][:account_code], unique_email_code, filename].join("/")
79
- AWS::S3::S3Object.store(path, attachment.body.decoded, bucket_name)
80
- url = AWS::S3::S3Object.url_for("#{path}", bucket_name, :expires_in => EmailHandler::TWENTYFOUR_HOURS)
74
+ path = ["", "attachments", @options[:mailbox][:account_code], unique_email_code, filename].join("/")[1..-1]
75
+ # AWS::S3::S3Object.store(path, attachment.body.decoded, bucket_name)
76
+ # url = AWS::S3::S3Object.url_for("#{path}", bucket_name, :expires_in => EmailHandler::TWENTYFOUR_HOURS)
77
+
78
+
79
+ s3 = Aws::S3::Resource.new(region: 'us-east-1')
80
+ obj = s3.bucket(bucket_name).object(path)
81
+ obj.put(body: attachment.body.decoded, acl: 'private')
82
+ url = obj.presigned_url(:get, expires_in: EmailHandler::TWENTYFOUR_HOURS)
81
83
 
82
84
  attachments << {
83
85
  "storage_type" => "S3",
84
86
  "filename" => attachment.filename,
85
- "filepath" => "/#{bucket_name}#{path}",
87
+ "filepath" => "#{bucket_name}/#{path}",
86
88
  "url" => url
87
89
  }
88
90
  end
@@ -26,8 +26,6 @@ module Mail2cb
26
26
  redis_url = URI.parse(ENV["REDIS_URL"])
27
27
 
28
28
  $redis = Redis.new(:host => redis_url.host, :port => redis_url.port)
29
- puts "GLOBAL REDIS"
30
- ap $redis
31
29
 
32
30
  Signal.trap("INT") {
33
31
  Thread.new {self.stop}.join
@@ -81,8 +79,7 @@ module Mail2cb
81
79
  and u.is_bot=1
82
80
  and u.is_account_admin=1
83
81
  EOS
84
- statement = mysql.prepare(sql)
85
- result = statement.execute()
82
+ result = mysql.query(sql)
86
83
  result.each do |row|
87
84
  ssl_options = row["imap_ssl"]==1 ? {:verify_mode => OpenSSL::SSL::VERIFY_NONE} : false
88
85
 
@@ -139,8 +136,7 @@ EOS
139
136
  end
140
137
  mysql_client do |mysql|
141
138
  status_message = options[:status]
142
- statement = mysql.prepare("UPDATE case_blocks_email_accounts SET imap_messages_processed='#{options[:mailbox][:message_count]}', imap_last_processed_at='#{options[:mailbox][:last_delivered_at]}' where id=?")
143
- statement.execute(options[:mailbox][:id])
139
+ mysql.query("UPDATE case_blocks_email_accounts SET imap_messages_processed='#{options[:mailbox][:message_count]}', imap_last_processed_at='#{options[:mailbox][:last_delivered_at]}' where id=#{options[:mailbox][:id]}")
144
140
  end
145
141
  rescue => e
146
142
  puts e.message
@@ -160,8 +156,7 @@ EOS
160
156
  end
161
157
  mysql_client do |mysql|
162
158
  status_message = options[:status]
163
- statement = mysql.prepare("UPDATE case_blocks_email_accounts SET imap_status='#{options[:status]}', imap_status_message='#{status_message}' where id=?")
164
- statement.execute(options[:mailbox][:id])
159
+ mysql.query("UPDATE case_blocks_email_accounts SET imap_status='#{options[:status]}', imap_status_message='#{status_message}' where id=#{options[:mailbox][:id]}")
165
160
  end
166
161
  rescue => e
167
162
  puts e.message
@@ -1,3 +1,3 @@
1
1
  module Mail2cb
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.15"
3
3
  end
data/mail2cb.gemspec CHANGED
@@ -19,23 +19,21 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.6"
22
- spec.add_development_dependency "rake"
23
- spec.add_development_dependency "awesome_print"
24
- spec.add_development_dependency "rspec"
25
- spec.add_development_dependency "timecop"
26
- spec.add_development_dependency "mock-aws-s3"
22
+ spec.add_development_dependency "rake", '~> 11.2', '>= 11.2.2'
23
+ spec.add_development_dependency "awesome_print", "~> 1.7"
24
+ spec.add_development_dependency "rspec", "~> 3.5"
25
+ spec.add_development_dependency "timecop", '~> 0.8.1'
26
+ spec.add_development_dependency "mock-aws-s3", '~> 0.6.0'
27
27
 
28
-
29
-
30
- spec.add_dependency 'mysql2'
31
- spec.add_dependency 'mail'
32
- spec.add_dependency 'mail_daemon', "~> 0.0.10"
33
- spec.add_dependency 'nokogiri'
34
- spec.add_dependency 'sinatra'
35
- spec.add_dependency 'sanitize'
36
- spec.add_dependency 'faye'
37
- spec.add_dependency 'redis'
38
- spec.add_dependency 'aws-s3'
28
+ spec.add_dependency 'mysql2', "~> 0.3.17"
29
+ spec.add_dependency 'mail', '~> 2.6', '>= 2.6.4'
30
+ spec.add_dependency 'mail_daemon', '~> 0.0.10'
31
+ spec.add_dependency 'nokogiri', '~> 1.6', '>= 1.6.8'
32
+ spec.add_dependency 'sinatra', '~> 1.4', '>= 1.4.6'
33
+ spec.add_dependency 'sanitize', '~> 4.1'
34
+ spec.add_dependency 'faye', '~> 1.1', '>= 1.1.2'
35
+ spec.add_dependency 'redis', '~> 3.2', '>= 3.2.2'
36
+ spec.add_dependency 'aws-sdk', '~> 2.2', '>= 2.2.2'
39
37
  spec.add_dependency 'rest-client', '~> 1.8'
40
38
 
41
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mail2cb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - EmergeAdapt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-29 00:00:00.000000000 Z
11
+ date: 2016-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,100 +28,112 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '11.2'
31
34
  - - ">="
32
35
  - !ruby/object:Gem::Version
33
- version: '0'
36
+ version: 11.2.2
34
37
  type: :development
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '11.2'
38
44
  - - ">="
39
45
  - !ruby/object:Gem::Version
40
- version: '0'
46
+ version: 11.2.2
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: awesome_print
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - ">="
51
+ - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: '0'
53
+ version: '1.7'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - ">="
58
+ - - "~>"
53
59
  - !ruby/object:Gem::Version
54
- version: '0'
60
+ version: '1.7'
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: rspec
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
- - - ">="
65
+ - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: '0'
67
+ version: '3.5'
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
- - - ">="
72
+ - - "~>"
67
73
  - !ruby/object:Gem::Version
68
- version: '0'
74
+ version: '3.5'
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: timecop
71
77
  requirement: !ruby/object:Gem::Requirement
72
78
  requirements:
73
- - - ">="
79
+ - - "~>"
74
80
  - !ruby/object:Gem::Version
75
- version: '0'
81
+ version: 0.8.1
76
82
  type: :development
77
83
  prerelease: false
78
84
  version_requirements: !ruby/object:Gem::Requirement
79
85
  requirements:
80
- - - ">="
86
+ - - "~>"
81
87
  - !ruby/object:Gem::Version
82
- version: '0'
88
+ version: 0.8.1
83
89
  - !ruby/object:Gem::Dependency
84
90
  name: mock-aws-s3
85
91
  requirement: !ruby/object:Gem::Requirement
86
92
  requirements:
87
- - - ">="
93
+ - - "~>"
88
94
  - !ruby/object:Gem::Version
89
- version: '0'
95
+ version: 0.6.0
90
96
  type: :development
91
97
  prerelease: false
92
98
  version_requirements: !ruby/object:Gem::Requirement
93
99
  requirements:
94
- - - ">="
100
+ - - "~>"
95
101
  - !ruby/object:Gem::Version
96
- version: '0'
102
+ version: 0.6.0
97
103
  - !ruby/object:Gem::Dependency
98
104
  name: mysql2
99
105
  requirement: !ruby/object:Gem::Requirement
100
106
  requirements:
101
- - - ">="
107
+ - - "~>"
102
108
  - !ruby/object:Gem::Version
103
- version: '0'
109
+ version: 0.3.17
104
110
  type: :runtime
105
111
  prerelease: false
106
112
  version_requirements: !ruby/object:Gem::Requirement
107
113
  requirements:
108
- - - ">="
114
+ - - "~>"
109
115
  - !ruby/object:Gem::Version
110
- version: '0'
116
+ version: 0.3.17
111
117
  - !ruby/object:Gem::Dependency
112
118
  name: mail
113
119
  requirement: !ruby/object:Gem::Requirement
114
120
  requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '2.6'
115
124
  - - ">="
116
125
  - !ruby/object:Gem::Version
117
- version: '0'
126
+ version: 2.6.4
118
127
  type: :runtime
119
128
  prerelease: false
120
129
  version_requirements: !ruby/object:Gem::Requirement
121
130
  requirements:
131
+ - - "~>"
132
+ - !ruby/object:Gem::Version
133
+ version: '2.6'
122
134
  - - ">="
123
135
  - !ruby/object:Gem::Version
124
- version: '0'
136
+ version: 2.6.4
125
137
  - !ruby/object:Gem::Dependency
126
138
  name: mail_daemon
127
139
  requirement: !ruby/object:Gem::Requirement
@@ -140,86 +152,116 @@ dependencies:
140
152
  name: nokogiri
141
153
  requirement: !ruby/object:Gem::Requirement
142
154
  requirements:
155
+ - - "~>"
156
+ - !ruby/object:Gem::Version
157
+ version: '1.6'
143
158
  - - ">="
144
159
  - !ruby/object:Gem::Version
145
- version: '0'
160
+ version: 1.6.8
146
161
  type: :runtime
147
162
  prerelease: false
148
163
  version_requirements: !ruby/object:Gem::Requirement
149
164
  requirements:
165
+ - - "~>"
166
+ - !ruby/object:Gem::Version
167
+ version: '1.6'
150
168
  - - ">="
151
169
  - !ruby/object:Gem::Version
152
- version: '0'
170
+ version: 1.6.8
153
171
  - !ruby/object:Gem::Dependency
154
172
  name: sinatra
155
173
  requirement: !ruby/object:Gem::Requirement
156
174
  requirements:
175
+ - - "~>"
176
+ - !ruby/object:Gem::Version
177
+ version: '1.4'
157
178
  - - ">="
158
179
  - !ruby/object:Gem::Version
159
- version: '0'
180
+ version: 1.4.6
160
181
  type: :runtime
161
182
  prerelease: false
162
183
  version_requirements: !ruby/object:Gem::Requirement
163
184
  requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '1.4'
164
188
  - - ">="
165
189
  - !ruby/object:Gem::Version
166
- version: '0'
190
+ version: 1.4.6
167
191
  - !ruby/object:Gem::Dependency
168
192
  name: sanitize
169
193
  requirement: !ruby/object:Gem::Requirement
170
194
  requirements:
171
- - - ">="
195
+ - - "~>"
172
196
  - !ruby/object:Gem::Version
173
- version: '0'
197
+ version: '4.1'
174
198
  type: :runtime
175
199
  prerelease: false
176
200
  version_requirements: !ruby/object:Gem::Requirement
177
201
  requirements:
178
- - - ">="
202
+ - - "~>"
179
203
  - !ruby/object:Gem::Version
180
- version: '0'
204
+ version: '4.1'
181
205
  - !ruby/object:Gem::Dependency
182
206
  name: faye
183
207
  requirement: !ruby/object:Gem::Requirement
184
208
  requirements:
209
+ - - "~>"
210
+ - !ruby/object:Gem::Version
211
+ version: '1.1'
185
212
  - - ">="
186
213
  - !ruby/object:Gem::Version
187
- version: '0'
214
+ version: 1.1.2
188
215
  type: :runtime
189
216
  prerelease: false
190
217
  version_requirements: !ruby/object:Gem::Requirement
191
218
  requirements:
219
+ - - "~>"
220
+ - !ruby/object:Gem::Version
221
+ version: '1.1'
192
222
  - - ">="
193
223
  - !ruby/object:Gem::Version
194
- version: '0'
224
+ version: 1.1.2
195
225
  - !ruby/object:Gem::Dependency
196
226
  name: redis
197
227
  requirement: !ruby/object:Gem::Requirement
198
228
  requirements:
229
+ - - "~>"
230
+ - !ruby/object:Gem::Version
231
+ version: '3.2'
199
232
  - - ">="
200
233
  - !ruby/object:Gem::Version
201
- version: '0'
234
+ version: 3.2.2
202
235
  type: :runtime
203
236
  prerelease: false
204
237
  version_requirements: !ruby/object:Gem::Requirement
205
238
  requirements:
239
+ - - "~>"
240
+ - !ruby/object:Gem::Version
241
+ version: '3.2'
206
242
  - - ">="
207
243
  - !ruby/object:Gem::Version
208
- version: '0'
244
+ version: 3.2.2
209
245
  - !ruby/object:Gem::Dependency
210
- name: aws-s3
246
+ name: aws-sdk
211
247
  requirement: !ruby/object:Gem::Requirement
212
248
  requirements:
249
+ - - "~>"
250
+ - !ruby/object:Gem::Version
251
+ version: '2.2'
213
252
  - - ">="
214
253
  - !ruby/object:Gem::Version
215
- version: '0'
254
+ version: 2.2.2
216
255
  type: :runtime
217
256
  prerelease: false
218
257
  version_requirements: !ruby/object:Gem::Requirement
219
258
  requirements:
259
+ - - "~>"
260
+ - !ruby/object:Gem::Version
261
+ version: '2.2'
220
262
  - - ">="
221
263
  - !ruby/object:Gem::Version
222
- version: '0'
264
+ version: 2.2.2
223
265
  - !ruby/object:Gem::Dependency
224
266
  name: rest-client
225
267
  requirement: !ruby/object:Gem::Requirement