wco_models 3.1.0.192 → 3.1.0.193

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: dbba6285ae64aa8c8bd1dbebcf4316b2ecb2e7d81f2143220d6e2d00e2b8833b
4
- data.tar.gz: 7fe94b7db4a4f1147c0634bfdbb772cb07295870a1bdec024c855eca46e7996f
3
+ metadata.gz: 7c53ddd403cc55954a1df11b9e56ced2f9e7c7c06d2bdd811d168fd67330ed4c
4
+ data.tar.gz: 6780da6d6ac23641ff9bfa637e10231df33a2e21898e0422cc4794d2f4a83777
5
5
  SHA512:
6
- metadata.gz: 194d52d31e7fc74009341a9d64008515b4510d0f804542308cb28d11617c41765ee536d683149a9dc412d26770ba17a805ca5feb89b509a59053565e617c599e
7
- data.tar.gz: 12e385987d60859fc429da32d697d7bd7dcd2c0e8fe37855b389e3b3bcafd6903e57816efe42accad974e8f6edd0b25a6709b0a14a6282d2661ce8ec5fc68d33
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.192
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