pg_rails 7.0.8.pre.alpha.58 → 7.0.8.pre.alpha.60
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3eb3aafda57a8e794a17ccabaf1b6e644332a7f55809b758deda8aa8c997f518
|
4
|
+
data.tar.gz: d71a2873a4d5edb08068b22251c06f2b9228ff597ddc4ff76ede7a904f9de34f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ae29225d2bc35ef096a3dd1d5ab7bf77065ad83ac636e76b6c061bafd7704f71639cef9a128d09ec5cf6ef8171e2b26f0cb542e7c1ce4db2cd43c603aeaee2f
|
7
|
+
data.tar.gz: 570053dacc414063f5d9a767f662a8436117df5b655ba9b2e534021ea674b014f8d9a6a4fb504453024737c0961070f366635dac1a2c8f40dd6db2e4772a3792
|
@@ -13,11 +13,9 @@ module PgEngine
|
|
13
13
|
|
14
14
|
# default delivery_method: :smtp
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
# FIXME: marcar el Email en la DB como fallido
|
20
|
-
pg_err err
|
16
|
+
rescue_from StandardError do |err|
|
17
|
+
pg_warn err, :error
|
18
|
+
@email.update_columns(status: :failed, status_detail: err.to_s) # rubocop:disable Rails/SkipsModelValidations
|
21
19
|
end
|
22
20
|
|
23
21
|
protected
|
@@ -45,7 +45,7 @@ class Email < ApplicationRecord
|
|
45
45
|
kredis_unique_list :logs
|
46
46
|
|
47
47
|
# TODO: y el fallido temporario?
|
48
|
-
enumerize :status, in: { pending: 0,
|
48
|
+
enumerize :status, in: { pending: 0, failed: 1, sent: 2, accepted: 3, delivered: 4, rejected: 5 }
|
49
49
|
|
50
50
|
validates :from_address, :to, :status, presence: true
|
51
51
|
|
@@ -3,65 +3,28 @@
|
|
3
3
|
module PgEngine
|
4
4
|
class EmailObserver
|
5
5
|
def self.delivered_email(message)
|
6
|
-
# content = get_content(message)
|
7
|
-
# subject = message.subject
|
8
|
-
|
9
|
-
# message.to puede ser un string o un array de strings
|
10
|
-
# to = [message.to].flatten.join(', ')
|
11
|
-
|
12
6
|
message_id = message.message_id
|
13
7
|
mailer = message.delivery_handler.to_s
|
14
8
|
status = get_status(message)
|
15
|
-
return if message['email'].blank?
|
16
|
-
|
17
|
-
# El objeto Email ya estaba creado. Agarro ese objeto y le actualizo las cosas
|
18
|
-
email = message['email'].unparsed_value
|
19
9
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
10
|
+
if message['email'].present?
|
11
|
+
email = message['email'].unparsed_value
|
12
|
+
email.update_columns(message_id:, mailer:, status:) # rubocop:disable Rails/SkipsModelValidations
|
13
|
+
email.encoded_eml.attach({ io: StringIO.new(message.encoded), filename: "email-#{email.id}.eml" })
|
14
|
+
else
|
15
|
+
pg_warn 'El mail no tenía objeto Email asociado.', :warn
|
16
|
+
# FIX: el content puede ser TXT
|
17
|
+
# Email.create!(message_id: message.message_id, body_html: message.encoded,
|
18
|
+
# subject: subject, recipient: recipient,
|
19
|
+
# date: DateTime.now, mailer: message.delivery_handler.to_s, associated: associated(message),
|
20
|
+
# status: get_status(message), observations: get_observations(message))
|
21
|
+
end
|
22
|
+
rescue StandardError => e
|
23
|
+
pg_warn e, :error
|
32
24
|
end
|
33
25
|
|
34
26
|
def self.get_status(message)
|
35
27
|
message.perform_deliveries ? :sent : :blocked
|
36
28
|
end
|
37
|
-
|
38
|
-
# def self.get_html_or_text(message)
|
39
|
-
# message.body.parts.find { |p| p.content_type.match(/multipart/).present? }
|
40
|
-
# part = message.body.parts.find { |p| p.content_type.match(/html/).present? }
|
41
|
-
# part = message.body.parts.find { |p| p.content_type.match(/text/).present? } if part.nil?
|
42
|
-
# part = message if part.nil?
|
43
|
-
# part.body.raw_source
|
44
|
-
# end
|
45
|
-
|
46
|
-
# def self.associated(message)
|
47
|
-
# return if message['associated'].blank?
|
48
|
-
|
49
|
-
# message['associated'].unparsed_value
|
50
|
-
# end
|
51
|
-
|
52
|
-
# def self.get_observations(message)
|
53
|
-
# return if message['observations'].blank?
|
54
|
-
|
55
|
-
# message['observations'].unparsed_value
|
56
|
-
# end
|
57
|
-
|
58
|
-
# def self.get_content(message)
|
59
|
-
# multipart = message.body.parts.find { |p| p.content_type.match(/multipart/).present? }
|
60
|
-
# part = multipart.presence || message
|
61
|
-
# get_html_or_text(part)
|
62
|
-
# rescue StandardError => e
|
63
|
-
# pg_err e
|
64
|
-
# ''
|
65
|
-
# end
|
66
29
|
end
|
67
30
|
end
|
data/pg_rails/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.0.8.pre.alpha.
|
4
|
+
version: 7.0.8.pre.alpha.60
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martín Rosso
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|