wco_models 3.1.0.191 → 3.1.0.193

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: 9bff74466afd78d598eeb38f3b23283337a17e0b5a8b92b0e26f845f0bb8911a
4
- data.tar.gz: e4f9e670080defcc68b180349aff8fd16b5de911bfc2951a97032f57a5a3400e
3
+ metadata.gz: 7c53ddd403cc55954a1df11b9e56ced2f9e7c7c06d2bdd811d168fd67330ed4c
4
+ data.tar.gz: 6780da6d6ac23641ff9bfa637e10231df33a2e21898e0422cc4794d2f4a83777
5
5
  SHA512:
6
- metadata.gz: 2aa5e46bf8e08e735d816278ecc948d47e99cd70e7c85e8d17bf7a7f196310c6096f12a14fd9d03158f426025580cec2648995c4325ff21bfe0940193f35ce73
7
- data.tar.gz: d59c6bd87089bbb5a3ac0092a365696cf0d0fde26c2eb2573f00a1b6bc304ba53b2ef96a45ffa8212ef43b17ac7a0c13fa8d9d4c0c464454ccc42c18f2bc2cc4
6
+ metadata.gz: 3fa3ad8806434774d813e9b6af35ea966665f9ad35b7613353df99c8b5ab4028cdafee1a4c5416ea6072387326615acfb8fe4ad00a8ecd11835fd024aeb10ac0
7
+ data.tar.gz: eb95c14521da85dc6c051af5934996de37e3fc0edbfe90ed97c03010439d35349ae58cdef11cbbdfd32f534464df154d68a80c831d5ed248aef418b34db9da24
@@ -37,6 +37,7 @@ class WcoEmail::EmailFilter
37
37
  ## 'and' - all conditions must match, for filter to match
38
38
  has_many :skip_conditions, class_name: '::WcoEmail::EmailFilterCondition', inverse_of: :email_skip_filter
39
39
  accepts_nested_attributes_for :skip_conditions, allow_destroy: true
40
+
40
41
  validate :validate_conditions
41
42
  def validate_conditions
42
43
  if conditions.length + skip_conditions.length == 0
@@ -42,6 +42,6 @@ class WcoEmail::EmailFilterAction
42
42
  if [ KIND_AUTORESPOND ].include?( kind )
43
43
  _value = WcoEmail::EmailTemplate.find( value )
44
44
  end
45
- "#{" " * indent }<EmailFilterAction #{kind} `#{_value}` />\n"
45
+ "#{" " * indent }<EFAction #{kind} `#{_value}` />\n"
46
46
  end
47
47
  end
@@ -18,15 +18,37 @@ class WcoEmail::EmailFilterCondition
18
18
  field :value
19
19
  validates :value, presence: true
20
20
 
21
+ def apply leadset:, message:
22
+ cond = self
23
+ reason = nil
24
+ case cond.field
25
+ when WcoEmail::FIELD_LEADSET
26
+ if cond.operator == WcoEmail::OPERATOR_NOT_HAS_TAG
27
+ this_tag = Wco::Tag.find cond.value
28
+ if leadset.tags.include?( this_tag )
29
+ ;
30
+ else
31
+ reason = "{email_skip_filter ? 'skip_' : ''}condition leadset not-has-tag #{this_tag} NOT met"
32
+ end
33
+ end
34
+ when WcoEmail::FIELD_TO
35
+ if message.to == cond.value
36
+ reason = "{email_skip_filter ? 'skip_' : ''}condition to = #{cond.value}"
37
+ end
38
+ end
39
+ return reason
40
+ end
41
+
42
+
21
43
  def to_s
22
44
  "<EFC #{field} #{operator} #{value} />"
23
45
  end
24
46
  def to_s_full indent: 0
25
47
  _value = value
26
- if [ OPERATOR_HAS_TAG, OPERATOR_NOT_HAS_TAG ].include?( operator )
48
+ if [ ::WcoEmail::OPERATOR_HAS_TAG, ::WcoEmail::OPERATOR_NOT_HAS_TAG ].include?( operator )
27
49
  _value = Wco::Tag.find( value )
28
50
  end
29
- "#{" " * indent }<EmailFilterCondition #{field} #{operator} `#{_value}` />\n"
51
+ "#{" " * indent }<EF#{email_skip_filter ? 'Skip' : ''}Condition #{field} #{operator} `#{_value}` />\n"
30
52
  end
31
53
  end
32
54
 
@@ -199,22 +199,8 @@ class WcoEmail::MessageStub
199
199
  reason = 'subject_exact'
200
200
  end
201
201
 
202
- filter.conditions.each do |cond|
203
- case cond.field
204
- when WcoEmail::FIELD_LEADSET
205
- if cond.operator == WcoEmail::OPERATOR_NOT_HAS_TAG
206
- this_tag = Wco::Tag.find cond.value
207
- if leadset.tags.include?( this_tag )
208
- ;
209
- else
210
- reason = "condition leadset not-has-tag #{this_tag} NOT met"
211
- end
212
- end
213
- when WcoEmail::FIELD_TO
214
- if @message.to == cond.value
215
- reason = "condition to = #{cond.value}"
216
- end
217
- end
202
+ filter.conditions.each do |scond|
203
+ reason ||= scond.apply(leadset: leadset, message: @message )
218
204
  end
219
205
 
220
206
  if reason
@@ -229,6 +215,10 @@ class WcoEmail::MessageStub
229
215
  skip_reason = 'skip_from_regex'
230
216
  end
231
217
 
218
+ filter.skip_conditions.each do |scond|
219
+ skip_reason ||= scond.apply(leadset: leadset, message: @message )
220
+ end
221
+
232
222
  if skip_reason
233
223
  puts! "NOT Applying filter #{filter} to conv #{@message.conversation} for matching #{skip_reason}" if DEBUG
234
224
  else
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.191
4
+ version: 3.1.0.193
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-21 00:00:00.000000000 Z
11
+ date: 2025-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ahoy_matey