pg_rails 7.0.8.pre.alpha.58 → 7.0.8.pre.alpha.59

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: b3d8524d771ec24a2b2728686f3823fe5f4d52ead73f969e99ba003361572b55
4
+ data.tar.gz: 2d6efcc793a2b907ba38b974c6b437bae06e1fb9a4bf15554d2d90434a13dc9e
5
5
  SHA512:
6
- metadata.gz: e2b01bcb36204063d7374404571501f387adeec187364b16b014e9d81f20ed892ffc576af1cb69e967bef31008a90f197e412e6760ce02f493610b0ae8fe5eac
7
- data.tar.gz: edfa1fbf40e2846af7c980f1bcbac849af13fe22ba5e4632ae7473795527a3da4b606f7e722d0dfc921017b71409f22010a79612bbcc34b7c137aa0815e51176
6
+ metadata.gz: 7fb40a82f52722779c7ac1dc58bc7c1d4c637ceed424861f8c927c7915c19d6c462e8800ee1e67dfcd9f5983052a7618967ffd84ee70ba8ba17771150b3bd677
7
+ data.tar.gz: 378f705720ae31579b3105c88e0d9d422ed8ad4c26b88bd5140b5fb3830fbcd005c6285681b19065576bd2be91f12feb5b52c6d943d2f29bcdcf6bed2ba0d365
@@ -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
16
  rescue_from MailNotDelivered do |err|
19
- # FIXME: marcar el Email en la DB como fallido
20
- pg_err 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.59'
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.59
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