mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 19:20:37 +02:00
Add full request JSON to bounced mail, remove unused views
This commit is contained in:
parent
6af37a787d
commit
834b2c95bc
10 changed files with 31 additions and 90 deletions
|
@ -1,23 +1,30 @@
|
|||
class BouncedMailAddress < ApplicationRecord
|
||||
validates :email, presence: true
|
||||
validates :bounce_reason, presence: true
|
||||
before_validation :assign_bounce_reason
|
||||
|
||||
def assign_bounce_reason
|
||||
self.bounce_reason = "#{action} (#{status} #{diagnostic})"
|
||||
end
|
||||
|
||||
def diagnostic
|
||||
response_json['diagnosticCode']
|
||||
recipient_json['diagnosticCode']
|
||||
end
|
||||
|
||||
def action
|
||||
response_json['action']
|
||||
recipient_json['action']
|
||||
end
|
||||
|
||||
def status
|
||||
response_json['status']
|
||||
recipient_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 = BouncedMailAddress.new(email: record['emailAddress'], recipient_json: record,
|
||||
response_json: json)
|
||||
|
||||
bounce_record.save
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue