effective_postmark 0.1.3 → 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: fa5fb599ef1e178681b95d7853d6215ea51446851e6ea2fed4087b3927a6832f
4
- data.tar.gz: 804b2ffcd11bc5f6a20df339b0ab4aa4bb5d3370eff443fbf807e71262846a6e
3
+ metadata.gz: 3c865f268155269e90bfab82beaca405a2adfed8b20c7156214f5b95574986c3
4
+ data.tar.gz: 183783ce5068b9b1abfdba98551d1a812a070f414a56f0fe787826a0855dd680
5
5
  SHA512:
6
- metadata.gz: dbe67ada0c62f056d6b1c8c5a373cee8470f7ad811409b4c25c5026a37ef66e0c879b1b9efd3386191f1ed8b565bb380228ea2e1feee9c5dd5f69ce37c5d4d68
7
- data.tar.gz: 68f60078392756c29eefe54e43ecdd8e437d7b885b1ec3c3f101c641228d73a9cddd091a0c158537a7bec4797d676e0c876b5299e90e1c25ea26d46517863857
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
@@ -3,8 +3,10 @@ module Admin
3
3
  before_action(:authenticate_user!) if defined?(Devise)
4
4
  before_action { EffectiveResources.authorize!(self, :admin, :effective_postmark) }
5
5
 
6
- def inactive_recipients
7
- @datatable = Admin::ReportInactiveRecipientsDatatable.new
6
+ include Effective::CrudController
7
+
8
+ def email_delivery_errors
9
+ @datatable = Admin::ReportEmailDeliveryErrorsDatatable.new
8
10
  @page_title = @datatable.datatable_name
9
11
 
10
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
@@ -1,9 +1,9 @@
1
1
  module EffectivePostmarkHelper
2
2
 
3
3
  # For use on the regular user alerts and forgot password pages
4
- def effective_postmark_alert(user, from: nil, html_class: 'alert alert-danger')
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
  [
@@ -19,9 +19,9 @@ module EffectivePostmarkHelper
19
19
  end
20
20
 
21
21
  # For use on the admin/users#edit page
22
- def effective_postmark_admin_alert(user, from: nil, html_class: 'alert alert-danger')
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
  [
@@ -29,7 +29,7 @@ module EffectivePostmarkHelper
29
29
  "They will not receive any emails",
30
30
  ("from #{from}" if from),
31
31
  "while inactive.",
32
- "Please update their email address, or" +
32
+ "Please update their email address, or " +
33
33
  link_to('reactivate their email', effective_postmark.postmark_reactivate_admin_postmark_path(user), 'data-method': :post),
34
34
  "and automatically attempt an email delivery."
35
35
  ].compact.join(' ').html_safe
@@ -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
@@ -0,0 +1,4 @@
1
+ %h1.effective-admin-heading= @page_title
2
+
3
+ = card do
4
+ = render_datatable(@datatable)
@@ -10,7 +10,7 @@ EffectivePostmark.setup do |config|
10
10
  # Please see config/initializers/effective_resources.rb for default effective_* gem mailer settings
11
11
  #
12
12
  # Configure the class responsible to send e-mails.
13
- # config.mailer = 'Effective::ClassifiedsMailer'
13
+ # config.mailer = 'Effective::PostmarkMailer'
14
14
  #
15
15
  # Override effective_resource mailer defaults
16
16
  #
@@ -0,0 +1,8 @@
1
+ en:
2
+ effective_postmark:
3
+ name: 'Effective Postmark'
4
+ acronym: 'Postmark'
5
+
6
+ datatables:
7
+ admin/report_email_delivery_errors_datatable: 'Report: Email Delivery Errors'
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.1.3'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_postmark
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-13 00:00:00.000000000 Z
11
+ date: 2024-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -218,14 +218,16 @@ 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
225
225
  - app/models/concerns/effective_postmark_user.rb
226
226
  - app/models/effective/postmark_api.rb
227
+ - app/views/admin/postmark_reports/index.html.haml
227
228
  - app/views/effective/postmark_mailer/reactivated.html.haml
228
229
  - config/effective_postmark.rb
230
+ - config/locales/effective_postmark.en.yml
229
231
  - config/routes.rb
230
232
  - db/migrate/101_create_effective_postmark.rb
231
233
  - db/seeds.rb