gitlab-mail_room 0.0.20 → 0.0.22

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
  SHA256:
3
- metadata.gz: d67e38380fdc5833ee32a9cacee0894a2f9533b869ada45847156a7d49e0130b
4
- data.tar.gz: 51c4d4449a80f38d06b99d3fd0f62c9ddf3760f3f55ec7611887ab9e583dc77a
3
+ metadata.gz: b83e39da2869147d1086529b11cfb371446aa616323dbc5c5212330d12f8fe9f
4
+ data.tar.gz: 96840ed2fb7347df81ba7c139f02d0613b0041979b28a9ae52c5879452898133
5
5
  SHA512:
6
- metadata.gz: d52fb679aa2b3395e91d4d0f055fc5fb7e709495c5172148a1439d2472ea45a47115824dcf2717aaaa7312679ef48614007ffd4d8d4358e671bb40b037177d72
7
- data.tar.gz: a4e43c65a7bd5561e2731a0056299f4c2f68c31c4854a91291f3d47874bccbefe9048f4872aef7a82750a3e4afdad4c7ac59e0c79c667bbc1b83006c35f2440a
6
+ metadata.gz: 6aff0a7be49b42b0d645414385988805d9fc283528876c7605b90c6535a364b40c09b2e2ca8909413238bc20e4a01e55b730c7361cee6db537a72fa60f38f422
7
+ data.tar.gz: dc9bf6c5edd55071cc512a30fc56981a50119d2f3dc0a02d18a7dfed5ac90160a7500404418ec80ddcc39db3947a091ede405132453312a145ac8886ce8d543a
data/.gitlab-ci.yml CHANGED
@@ -6,6 +6,7 @@ services:
6
6
 
7
7
  .test-template: &test
8
8
  cache:
9
+ key: ruby-$RUBY_VERSION
9
10
  paths:
10
11
  - vendor/ruby
11
12
  variables:
@@ -22,7 +23,7 @@ services:
22
23
  rspec:
23
24
  parallel:
24
25
  matrix:
25
- - RUBY_VERSION: [ "2.5", "2.6", "2.7", "3.0" ]
26
+ - RUBY_VERSION: [ "2.6", "2.7", "3.0", "3.1", "3.2" ]
26
27
  <<: *test
27
28
 
28
29
  include:
data/README.md CHANGED
@@ -379,8 +379,8 @@ And finally, configure MailRoom to use the postback configuration with the optio
379
379
  :delivery_method: postback
380
380
  :delivery_options:
381
381
  :delivery_url: https://example.com/rails/action_mailbox/relay/inbound_emails
382
- :delivery_username: actionmailbox
383
- :delivery_password: <INGRESS_PASSWORD>
382
+ :username: actionmailbox
383
+ :password: <INGRESS_PASSWORD>
384
384
  ```
385
385
 
386
386
  ## Receiving `postback` in Rails ##
@@ -20,8 +20,12 @@ module MailRoom
20
20
 
21
21
  jwt = initialize_jwt(mailbox.delivery_options)
22
22
 
23
- username = mailbox.delivery_options[:username]
24
- password = mailbox.delivery_options[:password]
23
+ username =
24
+ mailbox.delivery_options[:username] ||
25
+ mailbox.delivery_options[:delivery_username]
26
+ password =
27
+ mailbox.delivery_options[:password] ||
28
+ mailbox.delivery_options[:delivery_password]
25
29
 
26
30
  logger = mailbox.logger
27
31
 
@@ -1,5 +1,6 @@
1
1
  require 'pg'
2
2
  require 'json'
3
+ require 'charlock_holmes'
3
4
 
4
5
  module MailRoom
5
6
  module Delivery
@@ -34,7 +35,7 @@ module MailRoom
34
35
  # deliver the message by pushing it onto the configured Sidekiq queue
35
36
  # @param message [String] the email message as a string, RFC822 format
36
37
  def deliver(message)
37
- queue_job(message)
38
+ queue_job(utf8_encode_message(message))
38
39
  @options.logger.info({ delivery_method: 'Que', action: 'message pushed' })
39
40
  end
40
41
 
@@ -58,6 +59,19 @@ module MailRoom
58
59
 
59
60
  connection.exec(sql, [options.priority, options.job_class, options.queue, JSON.dump(args)])
60
61
  end
62
+
63
+ def utf8_encode_message(message)
64
+ message = message.dup
65
+
66
+ message.force_encoding("UTF-8")
67
+ return message if message.valid_encoding?
68
+
69
+ detection = CharlockHolmes::EncodingDetector.detect(message)
70
+ return message unless detection && detection[:encoding]
71
+
72
+ # Convert non-UTF-8 body UTF-8 so it can be dumped as JSON.
73
+ CharlockHolmes::Converter.convert(message, detection[:encoding], 'UTF-8')
74
+ end
61
75
  end
62
76
  end
63
77
  end
@@ -1,4 +1,4 @@
1
1
  module MailRoom
2
2
  # Current version of gitlab-mail_room gem
3
- VERSION = "0.0.20"
3
+ VERSION = "0.0.22"
4
4
  end
data/mail_room.gemspec CHANGED
@@ -21,9 +21,6 @@ Gem::Specification.new do |gem|
21
21
  gem.add_dependency "oauth2", "~> 1.4.4"
22
22
  gem.add_dependency "jwt", ">= 2.0"
23
23
 
24
- # Pinning io-wait to 0.1.0, which is the last version to support Ruby < 3
25
- gem.add_dependency "io-wait", "~> 0.1.0"
26
-
27
24
  gem.add_development_dependency "rake"
28
25
  gem.add_development_dependency "rspec", "~> 3.9"
29
26
  gem.add_development_dependency "rubocop", "~> 1.11"
@@ -4,12 +4,13 @@ require 'mail_room/delivery/letter_opener'
4
4
  describe MailRoom::Delivery::LetterOpener do
5
5
  describe '#deliver' do
6
6
  let(:mailbox) {build_mailbox(location: '/tmp/somewhere')}
7
- let(:delivery_method) {stub(:deliver!)}
7
+ let(:delivery_method) {stub}
8
8
  let(:mail) {stub}
9
9
 
10
10
  before :each do
11
11
  Mail.stubs(:read_from_string).returns(mail)
12
12
  ::LetterOpener::DeliveryMethod.stubs(:new).returns(delivery_method)
13
+ delivery_method.stubs(:deliver!)
13
14
  end
14
15
 
15
16
  it 'creates a new LetterOpener::DeliveryMethod' do
@@ -19,7 +19,8 @@ describe MailRoom::Delivery::Logger do
19
19
  let(:mailbox) {build_mailbox(log_path: '/var/log/mail-room.log')}
20
20
 
21
21
  it 'creates a new file to append to' do
22
- file = stub(:sync=)
22
+ file = stub
23
+ file.stubs(:sync=)
23
24
 
24
25
  File.expects(:open).with('/var/log/mail-room.log', 'a').returns(file)
25
26
  ::Logger.stubs(:new).with(file)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-mail_room
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.20
4
+ version: 0.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Pitale
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-15 00:00:00.000000000 Z
11
+ date: 2023-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-imap
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.0'
55
- - !ruby/object:Gem::Dependency
56
- name: io-wait
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: 0.1.0
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: 0.1.0
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: rake
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -341,7 +327,7 @@ files:
341
327
  homepage: http://github.com/tpitale/mail_room
342
328
  licenses: []
343
329
  metadata: {}
344
- post_install_message:
330
+ post_install_message:
345
331
  rdoc_options: []
346
332
  require_paths:
347
333
  - lib
@@ -356,8 +342,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
356
342
  - !ruby/object:Gem::Version
357
343
  version: '0'
358
344
  requirements: []
359
- rubygems_version: 3.1.6
360
- signing_key:
345
+ rubygems_version: 3.4.7
346
+ signing_key:
361
347
  specification_version: 4
362
348
  summary: mail_room will proxy email (gmail) from IMAP to a callback URL, logger, or
363
349
  letter_opener