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: 418b790d06e3fdd8000b1722d68c479728e29eca73c1181544cf9241aed5745a
4
- data.tar.gz: ec5ae58ada69aacb782c37374051022747b41049bd8cdd4824dac3f278a92325
3
+ metadata.gz: 3eb3aafda57a8e794a17ccabaf1b6e644332a7f55809b758deda8aa8c997f518
4
+ data.tar.gz: d71a2873a4d5edb08068b22251c06f2b9228ff597ddc4ff76ede7a904f9de34f
5
5
  SHA512:
6
- metadata.gz: e2b01bcb36204063d7374404571501f387adeec187364b16b014e9d81f20ed892ffc576af1cb69e967bef31008a90f197e412e6760ce02f493610b0ae8fe5eac
7
- data.tar.gz: edfa1fbf40e2846af7c980f1bcbac849af13fe22ba5e4632ae7473795527a3da4b606f7e722d0dfc921017b71409f22010a79612bbcc34b7c137aa0815e51176
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
- # TODO: rescue from StandardError? from PgEngine::Error?
17
-
18
- rescue_from MailNotDelivered do |err|
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, blocked: 1, sent: 2, accepted: 3, delivered: 4, rejected: 5 }
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
- email.encoded_eml.attach({ io: StringIO.new(message.encoded), filename: "email-#{email.id}.eml" })
21
-
22
- email.update_columns(message_id:, mailer:, status:) # rubocop:disable Rails/SkipsModelValidations
23
- # else
24
- # TODO: crear email
25
- # pg_warn 'El mail no tenía objeto Email asociado, se creó uno on the fly.', :warn
26
- # # No hay objeto Email, entonces le creo uno para que quede logueado.
27
- # # TODO: el content puede ser TXT
28
- # Email.create!(message_id: message.message_id, body_html: message.encoded,
29
- # subject: subject, recipient: recipient,
30
- # date: DateTime.now, mailer: message.delivery_handler.to_s, associated: associated(message),
31
- # status: get_status(message), observations: get_observations(message))
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRails
4
- VERSION = '7.0.8-alpha.58'
4
+ VERSION = '7.0.8-alpha.60'
5
5
  end
@@ -7,3 +7,5 @@ $danger-bg-subtle: tint-color($danger, 98%);
7
7
  // $info-border-subtle: tint-color($info, 60%);
8
8
  $warning-border-subtle: tint-color($warning, 20%);
9
9
  // $danger-border-subtle: tint-color($danger, 60%);
10
+
11
+ $btn-close-focus-shadow: none;
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.58
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-07 00:00:00.000000000 Z
11
+ date: 2024-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails