wco_models 3.1.0.91 → 3.1.0.92

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: c267b89943c2cb18139bdd044522d142fca56a81cadd7930b21eec7f6349d813
4
- data.tar.gz: 42c005b73cdb2d15d3157b2d485a57166519a594383caf5a959400c18ae693cb
3
+ metadata.gz: 8acb70bd0285b4695c50cab2fa2c2338fa51dacb535df93fcfa805cd58e47f6f
4
+ data.tar.gz: 0c1ce2b3a16a79982db08be8d129eced17acbf36cc246c6b095fbed813f14c43
5
5
  SHA512:
6
- metadata.gz: 77f0973a4e5ecddd767b045a6c77a5ba6b1dc98eacef09931fbc71413143f5966a3104fa763526f61b0f4a96029b082b025918423146e8703c434469455e74a5
7
- data.tar.gz: 564da09016bf7490ad15c0c394d15ffb1b453f610536dc4bd9f0cafb8fa8e855f6d7a66c999c5e7f75c4347157ec3a1cbe5e99d77a6dac1809555fe89757e6e0
6
+ metadata.gz: efd8df489b52203a347f640a572433eb71f567de9454ac5de57d2949f08de48836d6dc394dd0bcc9ac025b7303004bb9575080618eebfc02d144f93d1efb871f
7
+ data.tar.gz: 6bf11e6d4cf82022a4db7d1f07e7fb520bbe47d4a9e00c15bf31ecb73c5c7576f3c12a46c808912da35ea24002df622b72ae895028e2d72dc3912f9c790de06f
@@ -28,6 +28,24 @@ class Wco::Lead
28
28
  self[:email] = a
29
29
  end
30
30
  end
31
+ def self.normalize_email a
32
+ a = a.downcase
33
+ if a.index('+')
34
+ a.slice!( a[a.index('+')...a.index('@')] )
35
+ end
36
+ return a
37
+ end
38
+ def self.find_or_create_by_email email
39
+ email = self.normalize_email email
40
+ out = where( email: email ).first
41
+ if !out
42
+ domain = email.split('@')[1]
43
+ leadset = Wco::Leadset.where( company_url: domain ).first
44
+ leadset ||= Wco::Leadset.create( company_url: domain, email: email )
45
+ out = create!( email: email, leadset: leadset )
46
+ end
47
+ return out
48
+ end
31
49
 
32
50
 
33
51
  has_one :photo, class_name: 'Wco::Photo'
@@ -86,17 +86,13 @@ class WcoEmail::MessageStub
86
86
 
87
87
  ## Leadset, Lead
88
88
  from = the_mail.from ? the_mail.from[0] : "nobody@unknown-doma.in"
89
- domain = from.split('@')[1]
90
- leadset = Wco::Leadset.where( company_url: domain.downcase ).first
91
- leadset ||= Wco::Leadset.create( company_url: domain.downcase, email: from.downcase )
92
- lead = Wco::Lead.find_or_create_by( email: from, leadset: leadset )
93
-
89
+ lead = Wco::Lead.find_or_create_by_email( from )
94
90
 
95
91
  message = WcoEmail::Message.unscoped.where( message_id: message_id ).first
96
92
  if message
97
93
  message.message_id = "#{Time.now.strftime('%Y%m%d')}-trash-#{message.message_id}"
98
94
  message.object_key = "#{Time.now.strftime('%Y%m%d')}-trash-#{message.object_key}"
99
- message.save!( validate: false )
95
+ message.save( validate: false )
100
96
  message.delete
101
97
  end
102
98
 
@@ -119,7 +115,7 @@ class WcoEmail::MessageStub
119
115
  tos: the_mail.to,
120
116
 
121
117
  cc: the_mail.cc ? the_mail.cc[0] : nil,
122
- ccs: the_mail.cc,
118
+ ccs: the_mail.cc,
123
119
  })
124
120
  puts! @message, '@message'
125
121
 
@@ -156,9 +152,7 @@ class WcoEmail::MessageStub
156
152
  conv.save
157
153
 
158
154
  the_mail.cc&.each do |cc|
159
- domain = cc.split('@')[1] rescue 'unknown.domain'
160
- leadset = Wco::Leadset.find_or_create_by( company_url: domain )
161
- Wco::Lead.find_or_create_by( email: cc, leadset: leadset )
155
+ Wco::Lead.find_or_create_by_email( cc )
162
156
  end
163
157
 
164
158
  conv.update_attributes({
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wco_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0.91
4
+ version: 3.1.0.92
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-18 00:00:00.000000000 Z
11
+ date: 2024-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3