wco_models 3.1.0.305 → 3.1.0.306

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ab5f3e9735c73de3708a8b0cedec3bba5b93a1f6c693396d6f6b492c5639702
4
- data.tar.gz: 94708879c3fc160e214afe8522e9bc792fdf046fa903f9c27151e237419189d3
3
+ metadata.gz: a8f5b0a2dee427291f2f6e91778c749bad1d27000cfaec5248c0d753575ab897
4
+ data.tar.gz: 115c8df45585c59d17889e95fbb4122c8fa9da60f58c0cbb32a6b021fb62c5a8
5
5
  SHA512:
6
- metadata.gz: 0d9e765a2b3b61a7641704fe779b297191fa7a8d2c167f5e7163f51d2a8fd0696839620e2864ad557bbbc0fa7b8b26366023f85c797ff0bb52c36b3bd59ec27f
7
- data.tar.gz: 453ab1dd3bd2f1acc9239445522836ce18064a6fbb16b54499db401044e86545702f344d0c1fb1e2099b911e19dbe4386d2b2828ccc237d2a0e3a982476ae5ec
6
+ metadata.gz: ab1f1a65f9e3109e5ad25ad1a930dcda540421e8bb90870ee1d35d9c564364f5915f1cfc091a69255bb3e6e511052b9ddb794e62071b2bb62af661add155e230
7
+ data.tar.gz: '0589b0ea20dc4c9a912e02f88576c19ccda762ccc3e0a96c5888491c4a70a2f5acd9f77cb62377da32767ef22521a18186e647212e9d952c34fe61cb33ca654e'
@@ -5,7 +5,7 @@ class Wco::Api::LeadsController < Wco::ApiController
5
5
  before_action :check_credentials, only: [ :by_email ]
6
6
 
7
7
  def by_email
8
- @lead = Wco::Lead.where( email: params[:email] ).first
8
+ @lead = Wco::Lead.find_or_create_by_email( params[:email] )
9
9
  end
10
10
 
11
11
  ## select2-leads-ajax
@@ -32,12 +32,7 @@ class Wco::Lead
32
32
  belongs_to :leadset, class_name: 'Wco::Leadset'
33
33
  before_validation :normalize_email, on: :create
34
34
  def normalize_email
35
- self[:email] = email.downcase
36
- if email.index('+')
37
- a = email
38
- a.slice!( a[a.index('+')...a.index('@')] )
39
- self[:email] = a
40
- end
35
+ self[:email] = Wco::Lead.normalize_email email
41
36
  end
42
37
  def self.normalize_email a
43
38
  a = a.downcase
@@ -49,19 +44,14 @@ class Wco::Lead
49
44
  before_validation :set_leadset, on: :create
50
45
  def set_leadset
51
46
  domain = email.split('@')[1]
52
- self.leadset ||= Wco::Leadset.find_or_create_by({ company_url: domain })
47
+ root_domain = PublicSuffix.domain(domain)
48
+ self.leadset ||= Wco::Leadset.find_or_create_by({ company_url: root_domain })
53
49
  end
54
50
 
55
51
  def self.find_or_create_by_email email
56
52
  email = self.normalize_email email
57
- out = where( email: email ).first
58
- if !out
59
- domain = email.split('@')[1]
60
- leadset = Wco::Leadset.where( company_url: domain ).first
61
- leadset ||= Wco::Leadset.create( company_url: domain, email: email )
62
- out = create!( email: email, leadset: leadset )
63
- end
64
- return out
53
+ out = where( email: email ).first
54
+ out ||= create!( email: email )
65
55
  end
66
56
 
67
57
 
@@ -49,7 +49,7 @@ class WcoEmail::EmailFilterCondition
49
49
 
50
50
  index({ email_filter_id: 1, field: 1, operator: 1, value: 1 }, unique: true )
51
51
 
52
- def apply lead:, leadset:, message:
52
+ def apply lead:, message:
53
53
  cond = self
54
54
  reason = nil
55
55
  case cond.field
@@ -67,7 +67,7 @@ class WcoEmail::EmailFilterCondition
67
67
  tag = Wco::Tag.find( cond.value ) rescue nil
68
68
  tag ||= Wco::Tag.where( slug: cond.value ).first
69
69
  if tag
70
- if leadset.tags.include?( tag ) ||
70
+ if lead.leadset.tags.include?( tag ) ||
71
71
  lead.tags.include?( tag )
72
72
 
73
73
  reason = "#{email_skip_filter ? 'skip_' : ''}condition TAGGED `#{tag.slug}`"
@@ -80,7 +80,7 @@ class WcoEmail::EmailFilterCondition
80
80
  tag = Wco::Tag.find( cond.value ) rescue nil
81
81
  tag ||= Wco::Tag.where( slug: cond.value ).first
82
82
  if tag
83
- if !leadset.tags.include?( tag ) &&
83
+ if !lead.leadset.tags.include?( tag ) &&
84
84
  !lead.tags.include?( tag )
85
85
 
86
86
  reason = "#{email_skip_filter ? 'skip_' : ''}condition NOT_TAGGED `#{tag.slug}`"
@@ -90,20 +90,6 @@ class WcoEmail::EmailFilterCondition
90
90
 
91
91
  end ## end case
92
92
 
93
- # when WcoEmail::FIELD_LEADSET
94
- # if cond.operator == WcoEmail::OPERATOR_NOT_HAS_TAG
95
- # this_tag = Wco::Tag.find cond.value
96
- # if leadset.tags.include?( this_tag )
97
- # ;
98
- # else
99
- # reason = "#{email_skip_filter ? 'skip_' : ''}condition leadset not-has-tag #{this_tag} NOT met"
100
- # end
101
- # end
102
- # when WcoEmail::FIELD_TO
103
- # if message.to == cond.value
104
- # reason = "{email_skip_filter ? 'skip_' : ''}condition to = #{cond.value}"
105
- # end
106
- # end
107
93
  return reason
108
94
  end
109
95
 
@@ -72,14 +72,12 @@ class WcoEmail::MessageStub
72
72
  })
73
73
  end
74
74
 
75
- ## Leadset, Lead
76
- # from = json['mail_from'] || "nobody@unknown-doma.in"
75
+ ## Lead, Leadset
77
76
  from = json['from'][/<([^>]+)>/, 1].downcase rescue json['mail_from']
78
77
  mail_from = json['mail_from']
79
78
  @lead = Wco::Lead.find_or_create_by_email( from )
80
79
  @conv.leads.push @lead
81
- @leadset = Wco::Leadset.from_email from
82
- @conv.leadsets.push @leadset
80
+ @conv.leadsets.push @lead.leadset
83
81
 
84
82
  ## message
85
83
  old_message = WcoEmail::Message.unscoped.where( message_id: message_id ).first
@@ -130,7 +128,7 @@ class WcoEmail::MessageStub
130
128
  reason = nil
131
129
 
132
130
  filter.conditions.each do |cond|
133
- reason ||= cond.apply(lead: @lead, leadset: @leadset, message: @message )
131
+ reason ||= cond.apply(lead: @lead, message: @message )
134
132
  end
135
133
 
136
134
  if reason
@@ -140,7 +138,7 @@ class WcoEmail::MessageStub
140
138
  skip_reason = nil
141
139
 
142
140
  filter.skip_conditions.each do |scond|
143
- skip_reason ||= scond.apply(lead: @lead, leadset: @leadset, message: @message )
141
+ skip_reason ||= scond.apply(lead: @lead, message: @message )
144
142
  end
145
143
 
146
144
  if skip_reason
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.305
4
+ version: 3.1.0.306
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-08-05 00:00:00.000000000 Z
11
+ date: 2026-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -290,6 +290,20 @@ dependencies:
290
290
  - - ">="
291
291
  - !ruby/object:Gem::Version
292
292
  version: '0'
293
+ - !ruby/object:Gem::Dependency
294
+ name: public_suffix
295
+ requirement: !ruby/object:Gem::Requirement
296
+ requirements:
297
+ - - ">="
298
+ - !ruby/object:Gem::Version
299
+ version: '0'
300
+ type: :runtime
301
+ prerelease: false
302
+ version_requirements: !ruby/object:Gem::Requirement
303
+ requirements:
304
+ - - ">="
305
+ - !ruby/object:Gem::Version
306
+ version: '0'
293
307
  - !ruby/object:Gem::Dependency
294
308
  name: rails
295
309
  requirement: !ruby/object:Gem::Requirement