diff --git a/app/models/bounced_mail_address.rb b/app/models/bounced_mail_address.rb index d8f6a037b..6609829da 100644 --- a/app/models/bounced_mail_address.rb +++ b/app/models/bounced_mail_address.rb @@ -1,2 +1,24 @@ class BouncedMailAddress < ApplicationRecord + validates :email, presence: true + validates :bounce_reason, presence: true + + def diagnostic + response_json['diagnosticCode'] + end + + def action + response_json['action'] + end + + def status + response_json['status'] + end + + def self.record(json) + bounced_records = json['bounce']['bouncedRecipients'] + bounced_records.each do |record| + bounce_record = BouncedMailAddress.new(email: record['emailAddress'], response_json: record) + bounce_record.save + end + end end diff --git a/app/views/admin/bounced_mail_addresses/index.html.erb b/app/views/admin/bounced_mail_addresses/index.html.erb index c2f95ca68..b6a019282 100644 --- a/app/views/admin/bounced_mail_addresses/index.html.erb +++ b/app/views/admin/bounced_mail_addresses/index.html.erb @@ -2,32 +2,37 @@

Bounced Mail Addresses

- - - - - - - - - - +
+
+
+
+
EmailBounce reasonIncidentsResponse json
+ + + + + + + + + + - - <% @bounced_mail_addresses.each do |mail_addr| %> - - - - - - - - - - <% end %> - -
EmailActionStatusDiagnosticTrackedActions
<%= mail_addr.email %><%= mail_addr.bounce_reason %><%= mail_addr.incidents %><%= mail_addr.response_json %><%= link_to 'Show', admin_bounced_mail_address_path(mail_addr) %><%= link_to 'Edit', edit_admin_bounced_mail_address_path(mail_addr) %><%= link_to 'Destroy', admin_bounced_mail_address_path(mail_addr), method: :delete, data: { confirm: 'Are you sure?' } %>
- -
- -<%= link_to 'New Bounced Mail Address', new_admin_bounced_mail_address_path %> + + <% @bounced_mail_addresses.each do |mail_addr| %> + + <%= mail_addr.email %> + <%= mail_addr.action %> + <%= mail_addr.status %> + <%= mail_addr.diagnostic %> + <%= mail_addr.created_at %> + <%= link_to 'Detailed', admin_bounced_mail_address_path(mail_addr) %> + <%= link_to 'Destroy', admin_bounced_mail_address_path(mail_addr), method: :delete, data: { confirm: 'Are you sure?' } %> + + <% end %> + + + + + +