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 +4 -4
- data/README.md +7 -7
- data/app/controllers/admin/postmark_reports_controller.rb +2 -2
- data/app/datatables/admin/{report_inactive_recipients_datatable.rb → report_email_delivery_errors_datatable.rb} +4 -5
- data/app/helpers/effective_postmark_helper.rb +2 -2
- data/app/models/concerns/effective_postmark_user.rb +9 -16
- data/config/locales/effective_postmark.en.yml +1 -1
- data/config/routes.rb +1 -1
- data/lib/effective_postmark/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c865f268155269e90bfab82beaca405a2adfed8b20c7156214f5b95574986c3
|
4
|
+
data.tar.gz: 183783ce5068b9b1abfdba98551d1a812a070f414a56f0fe787826a0855dd680
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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, :
|
42
|
-
add_column :users, :
|
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.
|
76
|
+
if resource.email_delivery_error.present?
|
77
77
|
flash.delete(:notice)
|
78
|
-
flash[:danger] = view_context.effective_postmark_alert(resource, from: '
|
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 '
|
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.
|
99
|
-
can(:index, Admin::
|
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
|
9
|
-
@datatable = Admin::
|
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
|
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 :
|
20
|
-
col :
|
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.
|
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.
|
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.
|
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
|
-
|
19
|
-
|
18
|
+
email_delivery_error :string
|
19
|
+
email_delivery_error_at :datetime
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
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 :
|
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
|
36
|
+
return if email_delivery_error.present? # If we already marked invalid, don't mark again
|
36
37
|
|
37
|
-
update_columns(
|
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(
|
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
|
data/config/routes.rb
CHANGED
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.
|
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/
|
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
|