wco_models 3.1.0.281 → 3.1.0.282

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: 5e871389c03f7b7e33798660fe7912956c6fe8566e05dbb81c0bc20141f01e13
4
- data.tar.gz: 4c8b4bff79cd331dd2e6787f99d3e3a3903a1fc68a674cf43a23b64e7fa4174c
3
+ metadata.gz: 4a6fddb4672781a9e3d71d44d8f0deab38445fef5d3eff40f1ca7308625353b8
4
+ data.tar.gz: a3da8cead3d38d759139ae681429aa3fc8a47141a6ed8923f1cd102005544bab
5
5
  SHA512:
6
- metadata.gz: 5b3bff49a429b81ec768e795fba286d1e90a9969373969f7dc37e2452bd180e4daa027c3780a5f8e768ae0837de0df7cd3dd4f9a9005e5d46cbee2e319379749
7
- data.tar.gz: 4faca2a40bec78da0ea2ad6511f0ea3842745ff32aa95de6edde922773a35a0fbe5210b6a90de1ca0c9847341c9ad41a7d77fa6af03e2d61ab50d731247c712f
6
+ metadata.gz: bdbfbfb015a96ca4fbf340a916742a88a671c902b48166eb184ac367a8d3f8712a5ce796ee5291cc6151e1e0ed69ea47560a22ae3c856db3cfab630a6329c65e
7
+ data.tar.gz: 7c81c2ba1884b5467ec74e401a72d97ed5a5fc7f932a0f8e86b6c90a643e7ba5d506b9f5d881f8683405dbac5a9811eb594280cd28d3cbde6c5e256e9a06ea7e
@@ -69,6 +69,9 @@ class Wco::Lead
69
69
 
70
70
  has_and_belongs_to_many :conversations, class_name: '::WcoEmail::Conversation', index: true
71
71
  def convs; conversations; end
72
+
73
+ has_many :office_actions, class_name: '::Wco::OfficeAction'
74
+
72
75
  has_many :email_contexts, class_name: '::WcoEmail::Context'
73
76
  def ctxs; email_contexts; end
74
77
  has_many :email_actions, class_name: '::WcoEmail::EmailAction'
@@ -11,13 +11,15 @@ class Wco::OfficeAction
11
11
  # field :descr, type: :string ## optional
12
12
 
13
13
  belongs_to :office_action_template, inverse_of: :office_action
14
+ belongs_to :lead, class_name: '::Wco::Lead'
15
+
14
16
  def tmpl
15
17
  office_action_template
16
18
  end
17
19
 
18
20
  STATUS_ACTIVE = 'active'
19
21
  STATUS_INACTIVE = 'inactive'
20
- STATUSS = [ STATUS_ACTIVE, STATUS_INACTIVE ]
22
+ STATUSES = [ STATUS_ACTIVE, STATUS_INACTIVE ]
21
23
  field :status, type: :string
22
24
  scope :active, ->{ where( status: STATUS_ACTIVE ) }
23
25
  attr_accessor :deactivate
@@ -63,9 +63,10 @@ AOL
63
63
  end
64
64
 
65
65
 
66
+ end
67
+ ::EF = WcoEmail::EmailFilter
66
68
 
67
-
68
-
69
+ =begin
69
70
 
70
71
  ##
71
72
  ## deprecated
@@ -84,17 +85,15 @@ AOL
84
85
  field :skip_to_exact
85
86
 
86
87
  ## @deprecated 2026-04-02, use email_filter_action::<KIND>
87
- KIND_AUTORESPOND_TMPL = 'autorespond-template'
88
- KIND_AUTORESPOND_EACT = 'autorespond-email-action'
89
- KIND_REMOVE_TAG = 'remove-tag'
90
- KIND_ADD_TAG = 'add-tag'
91
- KIND_DESTROY_SCHS = 'destroy-schs'
92
- KIND_OAT = 'office-action'
93
-
94
- ## @deprecated
95
- KIND_AUTORESPOND = 'autorespond' ## @deprecated, DO NOT USE!
96
- KIND_DELETE = 'delete' ## @deprecated, use add-tag
97
- KIND_SKIP_INBOX = 'skip-inbox' ## @deprecated, use remove-tag
88
+ # KIND_AUTORESPOND_TMPL = 'autorespond-template'
89
+ # KIND_AUTORESPOND_EACT = 'autorespond-email-action'
90
+ # KIND_REMOVE_TAG = 'remove-tag'
91
+ # KIND_ADD_TAG = 'add-tag'
92
+ # KIND_DESTROY_SCHS = 'destroy-schs'
93
+ # KIND_OAT = 'office-action'
94
+ # KIND_AUTORESPOND = 'autorespond' ## @deprecated, DO NOT USE!
95
+ # KIND_DELETE = 'delete' ## @deprecated, use add-tag
96
+ # KIND_SKIP_INBOX = 'skip-inbox' ## @deprecated, use remove-tag
98
97
 
99
98
  KINDS = [ nil, KIND_OAT, KIND_AUTORESPOND_TMPL, KIND_AUTORESPOND_EACT, KIND_ADD_TAG, KIND_REMOVE_TAG, KIND_DESTROY_SCHS ]
100
99
  field :kind ## @deprecated, use filter.action.aject.kind 2026-04-02
@@ -117,5 +116,7 @@ AOL
117
116
  # return "<EF #{attrs}>#{children}</EF>\n"
118
117
  # end
119
118
 
120
- end
121
- ::EF = WcoEmail::EmailFilter
119
+ =end
120
+
121
+
122
+
@@ -6,15 +6,16 @@ class WcoEmail::EmailFilterAction
6
6
 
7
7
  belongs_to :email_filter
8
8
 
9
- KIND_AUTORESPOND = 'autorespond-template'
10
- # KIND_EXE_RB = 'exe-rb'
11
9
  KIND_ADD_TAG = 'add-tag'
12
10
  KIND_RM_TAG = 'remove-tag'
13
- KIND_EAT = 'autorespond-email-action'
14
- KIND_RM_EAT = 'rm-email-action'
11
+ KIND_AUTORESPOND = 'autorespond-template'
12
+ # KIND_EAT = 'autorespond-email-action' ## _TODO: not implemented!
13
+ # KIND_RM_EAT = 'rm-email-action' ## _TODO: not implemented!
15
14
  KIND_OAT = 'office-action-template'
16
15
  KIND_RM_OAT = 'rm-office-action-template'
17
- KINDS = [ KIND_ADD_TAG, KIND_RM_TAG, KIND_AUTORESPOND, KIND_OAT, KIND_EAT, KIND_RM_EAT ]
16
+ KINDS = [ KIND_ADD_TAG, KIND_RM_TAG, KIND_AUTORESPOND, KIND_OAT,
17
+ # KIND_EAT, KIND_RM_EAT,
18
+ ];
18
19
  field :kind
19
20
  validates :kind, inclusion: KINDS
20
21
 
@@ -85,22 +85,16 @@ class WcoEmail::Message
85
85
 
86
86
  def apply_filter_action action
87
87
  message = self
88
-
88
+ aject = action.aject
89
89
  case action.kind
90
- when WcoEmail::EmailFilterAction::KIND_OAT
90
+ when WcoEmail::EmailFilterAction::KIND_ADD_TAG
91
+ conv.tags.push aject
92
+ if aject == Wco::Tag.trash || aject == Wco::Tag.spam
93
+ conv.tags -= [ Wco::Tag.inbox ]
94
+ end
91
95
 
92
- config = {
93
- 'email_message_id' => message.id.to_s,
94
- 'lead_id' => message.lead_id.to_s,
95
- # 'message_id' => message.id.to_s,
96
- 'stub_id' => message.stub_id.to_s,
97
- }
98
- oa = Wco::OfficeAction.create!({
99
- office_action_template: action.aject,
100
- status: 'active',
101
- perform_at: Time.now,
102
- config: config,
103
- })
96
+ when WcoEmail::EmailFilterAction::KIND_RM_TAG
97
+ conv.tags -= [ aject ]
104
98
 
105
99
  when WcoEmail::EmailFilterAction::KIND_AUTORESPOND
106
100
  ctx = WcoEmail::Context.new({
@@ -113,81 +107,30 @@ class WcoEmail::Message
113
107
  end
114
108
  ctx.save!
115
109
 
116
- end
117
- end
118
-
119
- def apply_filter filter
120
- puts! filter, 'WcoEmail::Message#apply_filter' if DEBUG
121
- conv.filters << filter
122
-
123
- case filter.kind
124
-
125
- when WcoEmail::EmailFilter::KIND_DESTROY_SCHS
126
- conv.tags.push Wco::Tag.trash
127
- conv.tags -= [ Wco::Tag.inbox ]
128
- lead.schs.each do |sch|
129
- sch.update_attributes!({ state: ::Sch::STATE_TRASH })
130
- end
131
-
132
- when WcoEmail::EmailFilter::KIND_ADD_TAG
133
- conv.tags.push filter.tag
134
- if filter.tag == Wco::Tag.trash || filter.tag == Wco::Tag.spam
135
- conv.tags -= [ Wco::Tag.inbox ]
136
- end
137
-
138
- when WcoEmail::EmailFilter::KIND_REMOVE_TAG
139
- conv.tags -= [ filter.tag ]
140
-
141
- when WcoEmail::EmailFilter::KIND_AUTORESPOND_TMPL
142
- ctx = WcoEmail::Context.new({
143
- email_template: filter.email_template,
144
- lead_id: lead.id,
145
- send_at: Time.now,
110
+ when WcoEmail::EmailFilterAction::KIND_OAT
111
+ config = {
112
+ 'email_message_id' => message.id.to_s,
113
+ # 'lead_id' => message.lead_id.to_s,
114
+ # 'stub_id' => message.stub_id.to_s,
115
+ }
116
+ oa = Wco::OfficeAction.create!({
117
+ office_action_template: aject,
118
+ lead: message.lead,
119
+ status: 'active',
120
+ perform_at: Time.now,
121
+ config: config,
146
122
  })
147
- if filter.email_template.respond_inline
148
- ctx.reply_to_message_id = self.id
149
- end
150
- ctx.save!
151
123
 
152
- when WcoEmail::EmailFilter::KIND_AUTORESPOND_EACT
153
- ##
154
- ## This error is normal:
155
- ## Mongoid::Errors::Validations `Email action template is already taken`
156
- ##
157
- out = Sch.create({
158
- email_action_template: filter.email_action_template,
159
- status: Sch::STATUS_ACTIVE,
160
- lead_id: lead.id,
161
- perform_at: Time.now,
162
- })
124
+ when WcoEmail::EmailFilterAction::KIND_RM_OAT
125
+ oa = Wco::OfficeAction.where({
126
+ office_action_template: aject,
127
+ lead: message.lead }).first
128
+ oa.update_attributes!({ status: 'inactive' })
163
129
 
164
- else
165
- if filter.actions.present?
166
- filter.actions.each do |act|
167
- case act.kind
168
- when ::WcoEmail::ACTION_REMOVE_TAG
169
- this_tag = Wco::Tag.find( act.value )
170
- conv.tags -= [ this_tag ]
171
- when ::WcoEmail::ACTION_ADD_TAG
172
- this_tag = Wco::Tag.find( act.value )
173
- conv.tags += [ this_tag ]
174
- when ::WcoEmail::ACTION_AUTORESPOND
175
- this_template = WcoEmail::EmailTemplate.find( act.value )
176
- WcoEmail::Context.create!({
177
- email_template: this_template,
178
- lead_id: lead.id,
179
- send_at: Time.now,
180
- })
181
- end
182
- end
183
- else
184
- raise "unknown filter kind: #{filter.kind}"
185
- end
186
130
  end
187
-
188
- conv.save!
189
131
  end
190
132
 
133
+
191
134
  ## From: https://stackoverflow.com/questions/24672834/how-do-i-remove-emoji-from-string/24673322
192
135
  def self.strip_emoji(text)
193
136
  text = '' if text.blank?
@@ -323,6 +266,82 @@ class WcoEmail::Message
323
266
  end
324
267
  ::Msg = WcoEmail::Message
325
268
 
269
+ =begin
270
+
271
+
272
+ ## @deprecated, use apply_filter_action ONLY
273
+ def apply_filter filter
274
+ puts! filter, 'WcoEmail::Message#apply_filter' if DEBUG
275
+ conv.filters << filter
276
+
277
+ case filter.kind
278
+
279
+ when WcoEmail::EmailFilter::KIND_DESTROY_SCHS
280
+ conv.tags.push Wco::Tag.trash
281
+ conv.tags -= [ Wco::Tag.inbox ]
282
+ lead.schs.each do |sch|
283
+ sch.update_attributes!({ state: ::Sch::STATE_TRASH })
284
+ end
285
+
286
+ when WcoEmail::EmailFilter::KIND_ADD_TAG
287
+ conv.tags.push filter.tag
288
+ if filter.tag == Wco::Tag.trash || filter.tag == Wco::Tag.spam
289
+ conv.tags -= [ Wco::Tag.inbox ]
290
+ end
291
+
292
+ when WcoEmail::EmailFilter::KIND_REMOVE_TAG
293
+ conv.tags -= [ filter.tag ]
294
+
295
+ when WcoEmail::EmailFilter::KIND_AUTORESPOND_TMPL
296
+ ctx = WcoEmail::Context.new({
297
+ email_template: filter.email_template,
298
+ lead_id: lead.id,
299
+ send_at: Time.now,
300
+ })
301
+ if filter.email_template.respond_inline
302
+ ctx.reply_to_message_id = self.id
303
+ end
304
+ ctx.save!
305
+
306
+ when WcoEmail::EmailFilter::KIND_AUTORESPOND_EACT
307
+ ##
308
+ ## This error is normal:
309
+ ## Mongoid::Errors::Validations `Email action template is already taken`
310
+ ##
311
+ out = Sch.create({
312
+ email_action_template: filter.email_action_template,
313
+ status: Sch::STATUS_ACTIVE,
314
+ lead_id: lead.id,
315
+ perform_at: Time.now,
316
+ })
317
+
318
+ else
319
+ if filter.actions.present?
320
+ filter.actions.each do |act|
321
+ case act.kind
322
+ when ::WcoEmail::ACTION_REMOVE_TAG
323
+ this_tag = Wco::Tag.find( act.value )
324
+ conv.tags -= [ this_tag ]
325
+ when ::WcoEmail::ACTION_ADD_TAG
326
+ this_tag = Wco::Tag.find( act.value )
327
+ conv.tags += [ this_tag ]
328
+ when ::WcoEmail::ACTION_AUTORESPOND
329
+ this_template = WcoEmail::EmailTemplate.find( act.value )
330
+ WcoEmail::Context.create!({
331
+ email_template: this_template,
332
+ lead_id: lead.id,
333
+ send_at: Time.now,
334
+ })
335
+ end
336
+ end
337
+ else
338
+ raise "unknown filter kind: #{filter.kind}"
339
+ end
340
+ end
341
+
342
+ conv.save!
343
+ end
326
344
 
345
+ =end
327
346
 
328
347
 
@@ -9,6 +9,7 @@ key = '01070861907736276273039d9ee-c69a3509-5c85-481d-822e-ba65c204e1ba-000000@e
9
9
  ## Only object_key, no validations.
10
10
  ## 2023-12-28 _vp_ Continue.
11
11
  ## 2024-01-05 LFG
12
+ ## 2026-07-10 LFG
12
13
  ##
13
14
  class WcoEmail::MessageStub
14
15
  include Mongoid::Document
@@ -131,21 +132,6 @@ class WcoEmail::MessageStub
131
132
  email_filters = WcoEmail::EmailFilter.all.active
132
133
  email_filters.each do |filter|
133
134
  reason = nil
134
- if filter.from_regex.present? && @message.from.downcase.match( filter.from_regex )
135
- reason = 'from_regex'
136
- end
137
- if filter.from_exact.present? && @message.from.downcase.include?( filter.from_exact.downcase )
138
- reason = 'from_exact'
139
- end
140
- if filter.body_exact.present? && @message.part_html&.include?( filter.body_exact )
141
- reason = 'body_exact'
142
- end
143
- if filter.subject_regex.present? && @message.subject.match( filter.subject_regex )
144
- reason = 'subject_regex'
145
- end
146
- if filter.subject_exact.present? && @message.subject.downcase.include?( filter.subject_exact.downcase )
147
- reason = 'subject_exact'
148
- end
149
135
 
150
136
  filter.conditions.each do |cond|
151
137
  reason ||= cond.apply(leadset: @leadset, message: @message )
@@ -156,19 +142,13 @@ class WcoEmail::MessageStub
156
142
 
157
143
  ## skip
158
144
  skip_reason = nil
159
- if filter.skip_to_exact.present? && @message.to&.downcase.include?( filter.skip_to_exact.downcase )
160
- skip_reason = 'skip_to_exact'
161
- end
162
- if filter.skip_from_regex.present? && @message.from.downcase.match( filter.skip_from_regex )
163
- skip_reason = 'skip_from_regex'
164
- end
165
145
 
166
146
  filter.skip_conditions.each do |scond|
167
147
  skip_reason ||= scond.apply(leadset: @leadset, message: @message )
168
148
  end
169
149
 
170
150
  if skip_reason
171
- puts! "NOT Applying filter #{filter} to conv #{@message.conversation} for matching #{skip_reason}" if DEBUG
151
+ puts! "NOT Applying2 filter #{filter} to conv #{@message.conversation} for matching #{skip_reason}" if DEBUG
172
152
  else
173
153
  @conv.filters << filter; @conv.save
174
154
  filter.actions.each do |action|
@@ -185,6 +165,12 @@ class WcoEmail::MessageStub
185
165
  end
186
166
 
187
167
 
168
+
169
+ end
170
+
171
+ =begin
172
+
173
+ ## @obsolete - I moved away from amazon.
188
174
  def do_process
189
175
  @client ||= Aws::S3::Client.new(::SES_S3_CREDENTIALS)
190
176
 
@@ -461,4 +447,4 @@ class WcoEmail::MessageStub
461
447
  message = ''
462
448
  end
463
449
 
464
- end
450
+ =end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wco_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0.281
4
+ version: 3.1.0.282
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev
@@ -526,7 +526,6 @@ files:
526
526
  - app/models/wco_email/email_template.rb
527
527
  - app/models/wco_email/message.rb
528
528
  - app/models/wco_email/message_stub.rb
529
- - app/models/wco_email/obfuscated_redirect.rb-trash
530
529
  - app/models/wco_email/unsubscribe.rb
531
530
  - app/models/wco_hosting/appliance.rb
532
531
  - app/models/wco_hosting/appliance_tmpl.rb
@@ -1,13 +0,0 @@
1
-
2
- class WcoEmail::ObfuscatedRedirect
3
- include Mongoid::Document
4
- include Mongoid::Timestamps
5
- store_in collection: 'office_obfuscated_redirects'
6
-
7
- field :to, type: :string
8
- validates :to, presence: true
9
-
10
- field :visited_at, type: DateTime
11
- field :visits, type: :array, default: []
12
-
13
- end