mirror of
https://github.com/internetee/registry.git
synced 2025-06-04 11:47:30 +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,47 +1,16 @@
|
|||
module Admin
|
||||
class BouncedMailAddressesController < BaseController
|
||||
before_action :set_bounced_mail_address, only: %i[show edit update destroy]
|
||||
before_action :set_bounced_mail_address, only: %i[show destroy]
|
||||
load_and_authorize_resource
|
||||
|
||||
# GET /bounced_mail_addresses
|
||||
def index
|
||||
@bounced_mail_addresses = BouncedMailAddress.all
|
||||
@bounced_mail_addresses = BouncedMailAddress.all.order(created_at: :desc)
|
||||
end
|
||||
|
||||
# GET /bounced_mail_addresses/1
|
||||
def show; end
|
||||
|
||||
# GET /bounced_mail_addresses/new
|
||||
def new
|
||||
@bounced_mail_address = BouncedMailAddress.new
|
||||
end
|
||||
|
||||
# GET /bounced_mail_addresses/1/edit
|
||||
def edit; end
|
||||
|
||||
# POST /bounced_mail_addresses
|
||||
def create
|
||||
@bounced_mail_address = BouncedMailAddress.new(bounced_mail_address_params)
|
||||
|
||||
if @bounced_mail_address.save
|
||||
redirect_to(
|
||||
admin_bounced_mail_addresses_url,
|
||||
notice: 'Bounced mail address was successfully created.'
|
||||
)
|
||||
else
|
||||
render(:new)
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /bounced_mail_addresses/1
|
||||
def update
|
||||
if @bounced_mail_address.update(bounced_mail_address_params)
|
||||
redirect_to(@bounced_mail_address, notice: 'Bounced mail address was successfully updated.')
|
||||
else
|
||||
render(:edit)
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /bounced_mail_addresses/1
|
||||
def destroy
|
||||
@bounced_mail_address.destroy
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
%li= link_to t('.blocked_domains'), admin_blocked_domains_path
|
||||
%li= link_to t('.reserved_domains'), admin_reserved_domains_path
|
||||
%li= link_to t('.disputed_domains'), admin_disputes_path
|
||||
%li= link_to t('.bounced_email_addresses'), admin_bounced_mail_addresses_path
|
||||
%li= link_to t('.epp_log'), admin_epp_logs_path(created_after: 'today')
|
||||
%li= link_to t('.repp_log'), admin_repp_logs_path(created_after: 'today')
|
||||
%li= link_to t('.que'), '/admin/que'
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
<%= form_for([:admin, @bounced_mail_address], html: { class: 'form-horizontal' }) do |form| %>
|
||||
<% if @bounced_mail_address.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2><%= pluralize(bounced_mail_address.errors.count, "error") %> prohibited this bounced_mail_address from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% @bounced_mail_address.errors.full_messages.each do |message| %>
|
||||
<li><%= message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="field">
|
||||
<%= form.label :email %>
|
||||
<%= form.text_field :email %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= form.label :bounce_reason %>
|
||||
<%= form.text_field :bounce_reason %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= form.label :incidents %>
|
||||
<%= form.number_field :incidents %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<%= form.label :response_json %>
|
||||
<%= form.text_field :response_json %>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<%= form.submit %>
|
||||
</div>
|
||||
<% end %>
|
|
@ -1,6 +0,0 @@
|
|||
<h1>Editing Bounced Mail Address</h1>
|
||||
|
||||
<%= render 'form', bounced_mail_address: @bounced_mail_address %>
|
||||
|
||||
<%= link_to 'Show', admin_bounced_mail_address_path(@bounced_mail_address)%> |
|
||||
<%= link_to 'Back', admin_bounced_mail_addresses_path %>
|
|
@ -1,5 +0,0 @@
|
|||
<h1>New Bounced Mail Address</h1>
|
||||
|
||||
<%= render 'form', bounced_mail_address: @bounced_mail_address %>
|
||||
|
||||
<%= link_to 'Back', admin_bounced_mail_addresses_path %>
|
|
@ -16,9 +16,13 @@
|
|||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Response json:</strong>
|
||||
<%= @bounced_mail_address.response_json %>
|
||||
<strong>Bounced recipient JSON:</strong>
|
||||
<pre><%= JSON.pretty_generate(@bounced_mail_address.recipient_json) %></pre>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Bounce payload:</strong>
|
||||
<pre><%= JSON.pretty_generate(@bounced_mail_address.response_json) %></pre>
|
||||
</p>
|
||||
|
||||
<%= link_to 'Edit', edit_admin_bounced_mail_address_path(@bounced_mail_address) %> |
|
||||
<%= link_to 'Back', admin_bounced_mail_addresses_path %>
|
||||
|
|
|
@ -14,6 +14,7 @@ en:
|
|||
blocked_domains: Blocked domains
|
||||
reserved_domains: Reserved domains
|
||||
disputed_domains: Disputed domains
|
||||
bounced_email_addresses: Bounced emails
|
||||
epp_log: EPP log
|
||||
repp_log: REPP log
|
||||
que: Que
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddRecipientJsonToBouncedMailAddress < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
add_column :bounced_mail_addresses, :recipient_json, :jsonb, null: false
|
||||
end
|
||||
end
|
|
@ -486,7 +486,8 @@ CREATE TABLE public.bounced_mail_addresses (
|
|||
incidents integer DEFAULT 1 NOT NULL,
|
||||
response_json jsonb,
|
||||
created_at timestamp(6) without time zone NOT NULL,
|
||||
updated_at timestamp(6) without time zone NOT NULL
|
||||
updated_at timestamp(6) without time zone NOT NULL,
|
||||
recipient_json jsonb NOT NULL
|
||||
);
|
||||
|
||||
|
||||
|
@ -4956,6 +4957,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
|||
('20200908131554'),
|
||||
('20200910085157'),
|
||||
('20200910102028'),
|
||||
('20200916125326');
|
||||
('20200916125326'),
|
||||
('20200917104213');
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue