wco_models 3.1.0.291 → 3.1.0.292
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 +4 -4
- data/app/controllers/wco/newspartials_controller.rb +0 -3
- data/app/controllers/wco/newsvideos_controller.rb +0 -3
- data/app/controllers/wco/reports_controller.rb +0 -3
- data/app/models/iro/position.rb +1 -2
- data/app/models/wco/gallery.rb +4 -0
- data/app/models/wco_email/conversation.rb +2 -0
- data/app/models/wco_email/message_stub.rb +0 -282
- data/app/views/wco/galleries/_form.haml +0 -6
- data/app/views/wco/galleries/_header.haml +0 -1
- data/app/views/wco/newsvideos/_form.haml +0 -3
- data/app/views/wco/reports/_form.haml +0 -4
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c6ed3eeab0711f51c9839597b8a06cffae834ec4a67e2204a75ed336eb9b5ec6
|
|
4
|
+
data.tar.gz: 9f9b96b2a6a399ef92a6212ecebcfdf719a0a89f751f4e67e2db9b8ec11dd5ce
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1f2cff251434c46f43086e1dcc38faf5dc2d720ace7d2f483daec9d997fbe9b902a19214aa715558b1ab90802557557b02d48b7ee8462e83e3e3d852587c4d08
|
|
7
|
+
data.tar.gz: d8a9e784562f8ecb54504df228f80dbedc29f6bbccb7de809c2319264b57870b25d2849c1ca8dd9f1bb3ddaa1a34163887858157547c42cdfe4b7be3f53a82ce
|
|
@@ -55,9 +55,6 @@ class Wco::NewspartialsController < Wco::ApplicationController
|
|
|
55
55
|
def index
|
|
56
56
|
authorize! :index, Wco::Newspartial
|
|
57
57
|
@newspartials = Wco::Newspartial.all
|
|
58
|
-
if params[:deleted]
|
|
59
|
-
@newspartials = Wco::Newspartial.unscoped.where( :deleted_at.ne => nil )
|
|
60
|
-
end
|
|
61
58
|
@newspartials = @newspartials.page( params[:newspartials_page] ).per( current_profile.per_page )
|
|
62
59
|
end
|
|
63
60
|
|
|
@@ -54,9 +54,6 @@ class Wco::NewsvideosController < Wco::ApplicationController
|
|
|
54
54
|
def index
|
|
55
55
|
authorize! :index, Wco::Newsvideo
|
|
56
56
|
@newsvideos = Wco::Newsvideo.all.order_by( created_at: :desc )
|
|
57
|
-
if params[:deleted]
|
|
58
|
-
@newsvideos = Wco::Newsvideo.unscoped.where( :deleted_at.ne => nil )
|
|
59
|
-
end
|
|
60
57
|
@newsvideos = @newsvideos.page( params[:newsvideos_page] ).per( current_profile.per_page )
|
|
61
58
|
end
|
|
62
59
|
|
|
@@ -44,9 +44,6 @@ class Wco::ReportsController < Wco::ApplicationController
|
|
|
44
44
|
def index
|
|
45
45
|
authorize! :index, Wco::Report
|
|
46
46
|
@reports = Wco::Report.all
|
|
47
|
-
if params[:deleted]
|
|
48
|
-
@reports = Wco::Report.unscoped.where( :deleted_at.ne => nil )
|
|
49
|
-
end
|
|
50
47
|
@reports = @reports.page( params[:reports_page] ).per( current_profile.per_page )
|
|
51
48
|
end
|
|
52
49
|
|
data/app/models/iro/position.rb
CHANGED
data/app/models/wco/gallery.rb
CHANGED
|
@@ -21,6 +21,8 @@ class WcoEmail::Conversation
|
|
|
21
21
|
field :latest_at, type: Time
|
|
22
22
|
index({ latest_at: -1 })
|
|
23
23
|
|
|
24
|
+
field :deleted_at, type: Time ## just in case... should be unused. _vp_ 2026-07-19
|
|
25
|
+
|
|
24
26
|
field :from_emails, type: :array, default: []
|
|
25
27
|
index({ from_emails: -1 })
|
|
26
28
|
|
|
@@ -70,7 +70,6 @@ class WcoEmail::MessageStub
|
|
|
70
70
|
@conv = WcoEmail::Conversation.unscoped.find_or_create_by({
|
|
71
71
|
subject: subject,
|
|
72
72
|
})
|
|
73
|
-
@conv.deleted_at = nil
|
|
74
73
|
end
|
|
75
74
|
|
|
76
75
|
## Leadset, Lead
|
|
@@ -166,284 +165,3 @@ class WcoEmail::MessageStub
|
|
|
166
165
|
|
|
167
166
|
|
|
168
167
|
end
|
|
169
|
-
|
|
170
|
-
=begin
|
|
171
|
-
|
|
172
|
-
## @obsolete - I moved away from amazon.
|
|
173
|
-
def do_process
|
|
174
|
-
@client ||= Aws::S3::Client.new(::SES_S3_CREDENTIALS)
|
|
175
|
-
|
|
176
|
-
stub = self
|
|
177
|
-
|
|
178
|
-
raw = @client.get_object( bucket: stub.bucket, key: stub.object_key ).body.read
|
|
179
|
-
raw = raw.encode('utf-8', invalid: :replace, undef: :replace, replace: '_' )
|
|
180
|
-
the_mail = Mail.new( raw )
|
|
181
|
-
# puts! the_mail, 'the_mail'
|
|
182
|
-
|
|
183
|
-
message_id = the_mail.header['message-id']&.decoded
|
|
184
|
-
message_id ||= "#{the_mail.date&.iso8601}::#{the_mail.from}"
|
|
185
|
-
# puts! message_id, 'message_id'
|
|
186
|
-
|
|
187
|
-
in_reply_to_id = the_mail.header['in-reply-to']&.to_s
|
|
188
|
-
# puts! in_reply_to_id, 'in_reply_to_id'
|
|
189
|
-
|
|
190
|
-
the_mail.to = [ 'NO-RECIPIENT' ] if !the_mail.to
|
|
191
|
-
subject = WcoEmail::Message.strip_emoji( the_mail.subject || '(wco-no-subject)' )
|
|
192
|
-
# puts! subject, 'subject'
|
|
193
|
-
|
|
194
|
-
## Conversation
|
|
195
|
-
if in_reply_to_id
|
|
196
|
-
in_reply_to_msg = WcoEmail::Message.where({ message_id: in_reply_to_id }).first
|
|
197
|
-
if !in_reply_to_msg
|
|
198
|
-
conv = WcoEmail::Conversation.find_or_create_by({
|
|
199
|
-
subject: subject,
|
|
200
|
-
})
|
|
201
|
-
in_reply_to_msg = WcoEmail::Message.find_or_create_by({
|
|
202
|
-
message_id: in_reply_to_id,
|
|
203
|
-
conversation: conv,
|
|
204
|
-
})
|
|
205
|
-
end
|
|
206
|
-
conv = in_reply_to_msg.conversation
|
|
207
|
-
else
|
|
208
|
-
conv = WcoEmail::Conversation.unscoped.find_or_create_by({
|
|
209
|
-
subject: subject,
|
|
210
|
-
})
|
|
211
|
-
conv.deleted_at = nil
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
## Leadset, Lead
|
|
216
|
-
from = the_mail.from ? the_mail.from[0] : "nobody@unknown-doma.in"
|
|
217
|
-
lead = Wco::Lead.find_or_create_by_email( from )
|
|
218
|
-
conv.leads.push lead
|
|
219
|
-
leadset = Wco::Leadset.from_email from
|
|
220
|
-
conv.leadsets.push leadset
|
|
221
|
-
|
|
222
|
-
message = WcoEmail::Message.unscoped.where( message_id: message_id ).first
|
|
223
|
-
if message
|
|
224
|
-
message.message_id = "#{Time.now.strftime('%Y%m%d')}-trash-#{message.message_id}"
|
|
225
|
-
message.object_key = "#{Time.now.strftime('%Y%m%d')}-trash-#{message.object_key}"
|
|
226
|
-
message.save( validate: false )
|
|
227
|
-
message.delete
|
|
228
|
-
end
|
|
229
|
-
|
|
230
|
-
@message = WcoEmail::Message.create!({
|
|
231
|
-
stub: stub,
|
|
232
|
-
conversation: conv,
|
|
233
|
-
lead: lead,
|
|
234
|
-
|
|
235
|
-
message_id: message_id,
|
|
236
|
-
in_reply_to_id: in_reply_to_id,
|
|
237
|
-
object_key: stub.object_key,
|
|
238
|
-
|
|
239
|
-
subject: subject,
|
|
240
|
-
date: the_mail.date,
|
|
241
|
-
|
|
242
|
-
from: from,
|
|
243
|
-
froms: the_mail.from,
|
|
244
|
-
|
|
245
|
-
to: the_mail.to ? the_mail.to[0] : nil,
|
|
246
|
-
tos: the_mail.to,
|
|
247
|
-
|
|
248
|
-
cc: the_mail.cc ? the_mail.cc[0] : nil,
|
|
249
|
-
ccs: the_mail.cc,
|
|
250
|
-
})
|
|
251
|
-
# puts! @message, '@message'
|
|
252
|
-
|
|
253
|
-
## Parts
|
|
254
|
-
the_mail.parts.each do |part|
|
|
255
|
-
@message.churn_subpart( part )
|
|
256
|
-
end
|
|
257
|
-
@message.save
|
|
258
|
-
|
|
259
|
-
if the_mail.parts.length == 0
|
|
260
|
-
body = the_mail.body.decoded.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?')
|
|
261
|
-
if the_mail.content_type&.include?('text/html')
|
|
262
|
-
@message.part_html = body
|
|
263
|
-
elsif the_mail.content_type&.include?('text/plain')
|
|
264
|
-
@message.part_html = "<pre>#{body}</pre>"
|
|
265
|
-
elsif the_mail.content_type.blank?
|
|
266
|
-
@message.part_html = "<pre>#{body}</pre>"
|
|
267
|
-
else
|
|
268
|
-
@message.logs.push "mail body of unknown type: #{the_mail.content_type}"
|
|
269
|
-
@message.part_html = "<pre>#{body}</pre>"
|
|
270
|
-
end
|
|
271
|
-
@message.save
|
|
272
|
-
end
|
|
273
|
-
|
|
274
|
-
## Attachments, which are parts (omit!)
|
|
275
|
-
# the_mail.attachments.each do |att|
|
|
276
|
-
# @message.save_attachment( att )
|
|
277
|
-
# end
|
|
278
|
-
|
|
279
|
-
if !@message.save
|
|
280
|
-
puts! @message.errors.full_messages.join(", "), "Could not save @message"
|
|
281
|
-
end
|
|
282
|
-
|
|
283
|
-
the_mail.cc&.each do |cc|
|
|
284
|
-
Wco::Lead.find_or_create_by_email( cc )
|
|
285
|
-
end
|
|
286
|
-
|
|
287
|
-
conv.update_attributes({
|
|
288
|
-
status: WcoEmail::Conversation::STATUS_UNREAD,
|
|
289
|
-
latest_at: the_mail.date || Time.now.to_datetime,
|
|
290
|
-
from_emails: ( conv.from_emails + the_mail.from ).uniq,
|
|
291
|
-
preview: @message.preview_str,
|
|
292
|
-
})
|
|
293
|
-
|
|
294
|
-
##
|
|
295
|
-
## Tags
|
|
296
|
-
##
|
|
297
|
-
conv.tags.push Wco::Tag.inbox
|
|
298
|
-
conv.tags.push stub.tags
|
|
299
|
-
conv.save
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
## Actions & Filters
|
|
303
|
-
email_filters = WcoEmail::EmailFilter.all.active
|
|
304
|
-
email_filters.each do |filter|
|
|
305
|
-
reason = nil
|
|
306
|
-
if filter.from_regex.present? && @message.from.downcase.match( filter.from_regex )
|
|
307
|
-
reason = 'from_regex'
|
|
308
|
-
end
|
|
309
|
-
if filter.from_exact.present? && @message.from.downcase.include?( filter.from_exact.downcase )
|
|
310
|
-
reason = 'from_exact'
|
|
311
|
-
end
|
|
312
|
-
if filter.body_exact.present? && @message.part_html&.include?( filter.body_exact )
|
|
313
|
-
reason = 'body_exact'
|
|
314
|
-
end
|
|
315
|
-
if filter.subject_regex.present? && @message.subject.match( filter.subject_regex )
|
|
316
|
-
reason = 'subject_regex'
|
|
317
|
-
end
|
|
318
|
-
if filter.subject_exact.present? && @message.subject.downcase.include?( filter.subject_exact.downcase )
|
|
319
|
-
reason = 'subject_exact'
|
|
320
|
-
end
|
|
321
|
-
|
|
322
|
-
filter.conditions.each do |cond|
|
|
323
|
-
reason ||= cond.apply(leadset: leadset, message: @message )
|
|
324
|
-
end
|
|
325
|
-
|
|
326
|
-
if reason
|
|
327
|
-
puts! "Applying filter #{filter} to conv #{@message.conversation} for matching #{reason}" if DEBUG
|
|
328
|
-
|
|
329
|
-
## skip
|
|
330
|
-
skip_reason = nil
|
|
331
|
-
if filter.skip_to_exact.present? && @message.to&.downcase.include?( filter.skip_to_exact.downcase )
|
|
332
|
-
skip_reason = 'skip_to_exact'
|
|
333
|
-
end
|
|
334
|
-
if filter.skip_from_regex.present? && @message.from.downcase.match( filter.skip_from_regex )
|
|
335
|
-
skip_reason = 'skip_from_regex'
|
|
336
|
-
end
|
|
337
|
-
|
|
338
|
-
filter.skip_conditions.each do |skip_cond|
|
|
339
|
-
skip_reason ||= skip_cond.apply(leadset: leadset, message: @message )
|
|
340
|
-
end
|
|
341
|
-
|
|
342
|
-
if skip_reason
|
|
343
|
-
puts! "NOT Applying filter #{filter} to conv #{@message.conversation} for matching #{skip_reason}" if DEBUG
|
|
344
|
-
else
|
|
345
|
-
@message.apply_filter( filter )
|
|
346
|
-
end
|
|
347
|
-
end
|
|
348
|
-
end
|
|
349
|
-
|
|
350
|
-
stub.update_attributes({ status: WcoEmail::MessageStub::STATUS_PROCESSED })
|
|
351
|
-
|
|
352
|
-
## Notification
|
|
353
|
-
config = JSON.parse(stub.config)
|
|
354
|
-
if config['skip_notification']
|
|
355
|
-
;
|
|
356
|
-
else
|
|
357
|
-
## 2024-07-30 I'm no longer sending these to google.
|
|
358
|
-
## 2024-11-03 restarted sending.
|
|
359
|
-
## 2025-01-23 no longer sending to google.
|
|
360
|
-
conv = WcoEmail::Conversation.find( conv.id )
|
|
361
|
-
if conv.tags.include? Wco::Tag.inbox
|
|
362
|
-
if defined?(::NOTIFY_TO_GOOGLE) && ::NOTIFY_TO_GOOGLE
|
|
363
|
-
out = WcoEmail::ApplicationMailer.forwarder_notify( @message.id.to_s )
|
|
364
|
-
Rails.env.production? ? out.deliver_later : out.deliver_now
|
|
365
|
-
end
|
|
366
|
-
end
|
|
367
|
-
end
|
|
368
|
-
|
|
369
|
-
puts 'stub-ok'
|
|
370
|
-
end
|
|
371
|
-
|
|
372
|
-
## This only saves a local message from mbox to s3.
|
|
373
|
-
def save_mbox_to_m3 message
|
|
374
|
-
the_mail = Mail.new(message)
|
|
375
|
-
key = the_mail.message_id || "no-key-#{Time.now.to_i}.#{rand(1000)}"
|
|
376
|
-
|
|
377
|
-
@stub = WcoEmail::MessageStub.create({
|
|
378
|
-
bucket: ::S3_CREDENTIALS[:bucket_ses],
|
|
379
|
-
object_key: key,
|
|
380
|
-
status: WcoEmail::MessageStub::STATUS_PENDING,
|
|
381
|
-
tags: [ @tag ],
|
|
382
|
-
})
|
|
383
|
-
if @stub.persisted?
|
|
384
|
-
@client.put_object({
|
|
385
|
-
body: message,
|
|
386
|
-
bucket: ::S3_CREDENTIALS[:bucket_ses],
|
|
387
|
-
key: key,
|
|
388
|
-
})
|
|
389
|
-
else
|
|
390
|
-
msg = @stub.errors.full_messages.join(", ")
|
|
391
|
-
puts! msg
|
|
392
|
-
Wco::Log.create({
|
|
393
|
-
message: "Stub duplicate object_key: #{key}",
|
|
394
|
-
class_name: 'WcoEmail::MessageStub',
|
|
395
|
-
raw_json: @stub.attributes.to_json,
|
|
396
|
-
tags: [ @tag ],
|
|
397
|
-
})
|
|
398
|
-
end
|
|
399
|
-
end
|
|
400
|
-
|
|
401
|
-
def self.mbox2stubs mbox_path, tagname:, skip:
|
|
402
|
-
skip ||= 0
|
|
403
|
-
self.new.mbox2stubs mbox_path, tagname: tagname, skip: skip
|
|
404
|
-
end
|
|
405
|
-
def mbox2stubs mbox_path, tagname:, skip:
|
|
406
|
-
puts 'Starting...'
|
|
407
|
-
skip ||= 0
|
|
408
|
-
|
|
409
|
-
@count = 1
|
|
410
|
-
@client ||= Aws::S3::Client.new({
|
|
411
|
-
region: ::S3_CREDENTIALS[:region_ses],
|
|
412
|
-
access_key_id: ::S3_CREDENTIALS[:access_key_id_ses],
|
|
413
|
-
secret_access_key: ::S3_CREDENTIALS[:secret_access_key_ses],
|
|
414
|
-
})
|
|
415
|
-
@tag = Wco::Tag.find_or_create_by({ slug: tagname })
|
|
416
|
-
|
|
417
|
-
message = nil
|
|
418
|
-
File.readlines(mbox_path, encoding: "ISO8859-1" ).each do |line|
|
|
419
|
-
if (line.match(/\AFrom /))
|
|
420
|
-
|
|
421
|
-
if message
|
|
422
|
-
if skip < @count
|
|
423
|
-
save_mbox_to_m3 message
|
|
424
|
-
print "#{@count}."
|
|
425
|
-
else
|
|
426
|
-
print "s-#{@count}."
|
|
427
|
-
end
|
|
428
|
-
@count += 1
|
|
429
|
-
end
|
|
430
|
-
message = ''
|
|
431
|
-
|
|
432
|
-
else
|
|
433
|
-
message << line.sub(/^\>From/, 'From')
|
|
434
|
-
end
|
|
435
|
-
end
|
|
436
|
-
|
|
437
|
-
if message
|
|
438
|
-
if skip < @count
|
|
439
|
-
save_mbox_to_m3 message
|
|
440
|
-
print "#{@count}."
|
|
441
|
-
else
|
|
442
|
-
print "s-#{@count}."
|
|
443
|
-
end
|
|
444
|
-
@count += 1
|
|
445
|
-
end
|
|
446
|
-
message = ''
|
|
447
|
-
end
|
|
448
|
-
|
|
449
|
-
=end
|