effective_postmark 0.2.0 → 0.3.0

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: 4fe7f11d545296d6955abe9f0c934d791f64ebfae9fa6c648715b8e9b27e836b
4
- data.tar.gz: a33fd5b23fbcb58730245be5201a8c1d965219f0e7c75116e79b0bdde57398a4
3
+ metadata.gz: 3c865f268155269e90bfab82beaca405a2adfed8b20c7156214f5b95574986c3
4
+ data.tar.gz: 183783ce5068b9b1abfdba98551d1a812a070f414a56f0fe787826a0855dd680
5
5
  SHA512:
6
- metadata.gz: 7a25ef0fe93ca7217e03370437f062254212db1f1eec2837b295e758ba045e4bc2c92429671646900d426d066c6c65e12d4ec029d7ef3433e8c3be21d7fa9259
7
- data.tar.gz: '0768ffeb2fb7b3f6f41d981418ce3206c6dcc63e827ab2f5f4e825c784427f9ec5adac8fa6528aaa7bad2066cbb3e688a4f204244c80a54096d235dc234d0975'
6
+ metadata.gz: d927becf5cb36887f8a3093975e6b5cf543d9fe34d73fa11900372ec9807d484a5b40ae7e7d7e5ed30fb3e01f702f765b582a038526d8151309e965c674694db
7
+ data.tar.gz: bf2041254c685af6d7c2dbe5f64c2ba3ecf9ae62a5fbee7dd0fafe319992361a8842fbe2a19b2f2cf746d1691050f1b5feaaca92ec75ac1f036a9617575b7d65
data/README.md CHANGED
@@ -38,8 +38,8 @@ And add two database fields to your user model:
38
38
  ```ruby
39
39
  class AddEffectivePostmarkFieldsToUsers < ActiveRecord::Migration[7.0]
40
40
  def change
41
- add_column :users, :postmark_error, :string
42
- add_column :users, :postmark_error_at, :datetime
41
+ add_column :users, :email_delivery_error, :string
42
+ add_column :users, :email_delivery_error_at, :datetime
43
43
  end
44
44
  end
45
45
  ```
@@ -73,9 +73,9 @@ If you want to include the inactive alert on the devise reset password page:
73
73
  ```ruby
74
74
  class Users::PasswordsController < Devise::PasswordsController
75
75
  after_action(only: :create) do
76
- if resource.try(:postmark_invalid?)
76
+ if resource.email_delivery_error.present?
77
77
  flash.delete(:notice)
78
- flash[:danger] = view_context.effective_postmark_alert(resource, from: 'MyARTA', html_class: '')
78
+ flash[:danger] = view_context.effective_postmark_alert(resource, from: 'My Site', html_class: '')
79
79
  end
80
80
  end
81
81
  end
@@ -86,7 +86,7 @@ end
86
86
  Add a link to the admin report:
87
87
 
88
88
  ```ruby
89
- = nav_link_to 'Inactive Recipients', effective_postmark.inactive_recipients_admin_postmark_reports_path
89
+ = nav_link_to 'Email Delivery Errors', effective_postmark.email_delivery_errors_admin_postmark_reports_path
90
90
  ```
91
91
 
92
92
  ### Permissions
@@ -95,8 +95,8 @@ Give the following permissions to your admin user:
95
95
 
96
96
  ```ruby
97
97
  can :admin, :effective_postmark
98
- can(:postmark_reactivate, User) { |user| user.postmark_invalid? }
99
- can(:index, Admin::ReportInactiveRecipientsDatatable)
98
+ can(:postmark_reactivate, User) { |user| user.email_delivery_error.present? }
99
+ can(:index, Admin::ReportEmailDeliveryErrorsDatatable)
100
100
  ```
101
101
 
102
102
  ## License
@@ -5,8 +5,8 @@ module Admin
5
5
 
6
6
  include Effective::CrudController
7
7
 
8
- def inactive_recipients
9
- @datatable = Admin::ReportInactiveRecipientsDatatable.new
8
+ def email_delivery_errors
9
+ @datatable = Admin::ReportEmailDeliveryErrorsDatatable.new
10
10
  @page_title = @datatable.datatable_name
11
11
 
12
12
  authorize! :index, @datatable
@@ -1,7 +1,6 @@
1
1
  # Postmark: Inactive Recipients
2
-
3
2
  module Admin
4
- class ReportInactiveRecipientsDatatable < Effective::Datatable
3
+ class ReportEmailDeliveryErrorsDatatable < Effective::Datatable
5
4
  datatable do
6
5
  col :id, visible: false
7
6
 
@@ -16,8 +15,8 @@ module Admin
16
15
  col :first_name, visible: false
17
16
  col :last_name, visible: false
18
17
 
19
- col :postmark_error
20
- col :postmark_error_at
18
+ col :email_delivery_error
19
+ col :email_delivery_error_at
21
20
 
22
21
  actions_col(actions: []) do |user|
23
22
  dropdown_link_to('Reactivate', effective_postmark.postmark_reactivate_admin_postmark_path(user), remote: true, method: :post)
@@ -26,7 +25,7 @@ module Admin
26
25
  end
27
26
 
28
27
  collection do
29
- current_user.class.postmark_inactive_recipients
28
+ current_user.class.with_email_delivery_errors
30
29
  end
31
30
  end
32
31
  end
@@ -3,7 +3,7 @@ module EffectivePostmarkHelper
3
3
  # For use on the regular user alerts and forgot password pages
4
4
  def effective_postmark_alert(user, from: nil, html_class: 'alert alert-danger mb-4')
5
5
  raise('expected an effective_postmark_user') unless user.class.try(:effective_postmark_user?)
6
- return unless user.postmark_invalid?
6
+ return unless user.email_delivery_error.present?
7
7
 
8
8
  content_tag(:div, class: html_class) do
9
9
  [
@@ -21,7 +21,7 @@ module EffectivePostmarkHelper
21
21
  # For use on the admin/users#edit page
22
22
  def effective_postmark_admin_alert(user, from: nil, html_class: 'alert alert-danger mb-4')
23
23
  raise('expected an effective_postmark_user') unless user.class.try(:effective_postmark_user?)
24
- return unless user.postmark_invalid?
24
+ return unless user.email_delivery_error.present?
25
25
 
26
26
  content_tag(:div, class: html_class) do
27
27
  [
@@ -15,15 +15,16 @@ module EffectivePostmarkUser
15
15
 
16
16
  included do
17
17
  effective_resource do
18
- postmark_error :string
19
- postmark_error_at :datetime
18
+ email_delivery_error :string
19
+ email_delivery_error_at :datetime
20
20
  end
21
21
 
22
- before_validation(if: -> { email_changed? && postmark_invalid? }) do
23
- assign_attributes(postmark_error: nil, postmark_error_at: nil)
22
+ # Clear any email errors if they change their email
23
+ before_validation(if: -> { email_changed? && email_delivery_error.present? }) do
24
+ assign_attributes(email_delivery_error: nil, email_delivery_error_at: nil)
24
25
  end
25
26
 
26
- scope :postmark_inactive_recipients, -> { where.not(postmark_error_at: nil) }
27
+ scope :with_email_delivery_errors, -> { where.not(email_delivery_error: nil) }
27
28
  end
28
29
 
29
30
  module ClassMethods
@@ -32,9 +33,9 @@ module EffectivePostmarkUser
32
33
 
33
34
  # Triggered by the EffectivePostmarkMailer concern when a Postmark::InactiveRecipientError is raised
34
35
  def postmark_inactive_recipient!
35
- return unless postmark_valid? # If we already marked invalid, don't mark again
36
+ return if email_delivery_error.present? # If we already marked invalid, don't mark again
36
37
 
37
- update_columns(postmark_error: 'Inactive Recipient', postmark_error_at: Time.zone.now)
38
+ update_columns(email_delivery_error: 'Inactive Recipient', email_delivery_error_at: Time.zone.now)
38
39
  end
39
40
 
40
41
  # Triggered by an admin to reactivate the email address
@@ -48,15 +49,7 @@ module EffectivePostmarkUser
48
49
  return false if message.kind_of?(Exception)
49
50
 
50
51
  # This worked. We've been reactivated. Clear the error
51
- update_columns(postmark_error: nil, postmark_error_at: nil)
52
- end
53
-
54
- def postmark_valid?
55
- postmark_error.blank?
56
- end
57
-
58
- def postmark_invalid?
59
- postmark_error.present?
52
+ update_columns(email_delivery_error: nil, email_delivery_error_at: nil)
60
53
  end
61
54
 
62
55
  end
@@ -4,5 +4,5 @@ en:
4
4
  acronym: 'Postmark'
5
5
 
6
6
  datatables:
7
- admin/report_inactive_recipients_datatable: 'Report: Inactive Recipients'
7
+ admin/report_email_delivery_errors_datatable: 'Report: Email Delivery Errors'
8
8
 
data/config/routes.rb CHANGED
@@ -6,7 +6,7 @@ EffectivePostmark::Engine.routes.draw do
6
6
 
7
7
  resources :postmark_reports, only: [] do
8
8
  collection do
9
- get :inactive_recipients
9
+ get :email_delivery_errors
10
10
  end
11
11
  end
12
12
  end
@@ -1,3 +1,3 @@
1
1
  module EffectivePostmark
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_postmark
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
@@ -218,7 +218,7 @@ files:
218
218
  - README.md
219
219
  - app/controllers/admin/postmark_controller.rb
220
220
  - app/controllers/admin/postmark_reports_controller.rb
221
- - app/datatables/admin/report_inactive_recipients_datatable.rb
221
+ - app/datatables/admin/report_email_delivery_errors_datatable.rb
222
222
  - app/helpers/effective_postmark_helper.rb
223
223
  - app/mailers/concerns/effective_postmark_mailer.rb
224
224
  - app/mailers/effective/postmark_mailer.rb