email-verification 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 83ce4cfc1479b9a813fbb6070b5404eb49de97d208076ffeddef16acaf3c41b9
4
- data.tar.gz: 7e20c62d626b0138d2d0c46a7bd63356dfa81923f11b46a6182098dba60152f9
3
+ metadata.gz: bd68753b7d1328e375501221b3341bc3742dbd4cc69ea5f061fd8be079f5ca12
4
+ data.tar.gz: 398c820a3ea4983a3fdc09bfc83c6ebadb27a5e619176b30a3865696f55cecf1
5
5
  SHA512:
6
- metadata.gz: 40c40dd21330f526b0ef3178d09cb37165e1ba9e1c41afb45a132a757bfdf523463da93d75f922e73b143ae8733898cf56685e2532f65fa326fca8b471dd5850
7
- data.tar.gz: '09ba495219c0ac2c4424fb98f5b8e7a0d672b535fc81ceac64e0f68768b8d7cfc9518eb4bc7d85078c0c45d70812bf0b604101a42dae58060e13e3dc285fab4c'
6
+ metadata.gz: 9b4e9a4ff5f5e37e4ff943fc473f3a467fa79097dd36401c9f3d529e033ba85b01a28a0f66f17da7c2b346ffe8fca06a9a9384c5df207959fc6cb312fc09b8b4
7
+ data.tar.gz: b7d5476b7d3dae7999e979dc16cf963f9a1e1932474417fbac73341d0a78127583dc2e5a3fd283e090b18e60eecc148c43f1f824466eb87e19d40c39c2149fad
@@ -25,9 +25,10 @@ module Email
25
25
  log("From: #{email.from&.first&.strip}. Subject: #{email.subject}")
26
26
 
27
27
  if settings_provided?(settings)
28
- matching_subject = settings[:subject].nil? || (!settings[:subject].nil? && email.subject =~ settings[:subject])
28
+ matching_address = email.from&.first&.strip == settings[:address]
29
+ matching_subject = settings[:subject].nil? || (!settings[:subject].nil? && !(email.subject =~ settings[:subject]).nil?)
29
30
 
30
- emails << email_body(email) if email.from&.first&.strip == settings[:address] && matching_subject
31
+ emails << email_body(email) if matching_address && matching_subject
31
32
  else
32
33
  emails << email_body(email)
33
34
  end
@@ -39,8 +40,8 @@ module Email
39
40
  end
40
41
 
41
42
  if settings_provided?(settings)
42
- message = emails&.first
43
- code = message&.match(settings[:regex])&.[](:match)
43
+ message = emails.first&.to_s
44
+ result = message&.match(settings[:regex])&.[](:match)
44
45
  else
45
46
  result = emails
46
47
  end
@@ -53,8 +54,17 @@ module Email
53
54
  end
54
55
 
55
56
  def email_body(email)
56
- body = (email.html_part || email.text_part || email)&.body&.decoded
57
- force_utf8(body)
57
+ body = (email.html_part || email.text_part || email)&.body
58
+
59
+ begin
60
+ body = body&.decoded
61
+ rescue Mail::UnknownEncodingType
62
+ body = body&.encoded
63
+ end
64
+
65
+ body = force_utf8(body) unless body.to_s.empty?
66
+
67
+ return body
58
68
  end
59
69
 
60
70
  def force_utf8(string)
@@ -15,7 +15,7 @@ module Email
15
15
 
16
16
  if settings_provided?(settings)
17
17
  matching_name = settings[:from].to_s.empty? || (!settings[:from].to_s.empty? && email.from.first.name == settings[:from])
18
- matching_subject = settings[:subject].nil? || (!settings[:subject].nil? && email.subject =~ settings[:subject])
18
+ matching_subject = settings[:subject].nil? || (!settings[:subject].nil? && !(email.subject =~ settings[:subject]).nil?)
19
19
 
20
20
  emails << email_body(email) if matching_name && matching_subject
21
21
  else
@@ -1,5 +1,5 @@
1
1
  module Email
2
2
  module Verification
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: email-verification
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Johnsson