mirror of
https://github.com/internetee/registry.git
synced 2025-07-05 02:33:35 +02:00
Merge branch 'story/116761157-contact-dyn-states' into staging
This commit is contained in:
commit
223b6b8b9f
6 changed files with 25 additions and 10 deletions
|
@ -35,7 +35,7 @@ module Repp
|
||||||
error! I18n.t('errors.messages.epp_authorization_error'), 401 unless domain.auth_info.eql? request.headers['Auth-Code']
|
error! I18n.t('errors.messages.epp_authorization_error'), 401 unless domain.auth_info.eql? request.headers['Auth-Code']
|
||||||
|
|
||||||
contact_repp_json = proc{|contact|
|
contact_repp_json = proc{|contact|
|
||||||
contact.attributes.slice("code", "name", "ident", "ident_type", "ident_country_code", "phone", "email", "street", "city", "zip","country_code", "statuses")
|
contact.as_json.slice("code", "name", "ident", "ident_type", "ident_country_code", "phone", "email", "street", "city", "zip","country_code", "statuses")
|
||||||
}
|
}
|
||||||
|
|
||||||
@response = {
|
@response = {
|
||||||
|
|
|
@ -51,6 +51,7 @@ class Admin::SettingsController < AdminController
|
||||||
:admin_contacts_max_count,
|
:admin_contacts_max_count,
|
||||||
:tech_contacts_min_count,
|
:tech_contacts_min_count,
|
||||||
:tech_contacts_max_count,
|
:tech_contacts_max_count,
|
||||||
|
:orphans_contacts_in_months,
|
||||||
:ds_digest_type,
|
:ds_digest_type,
|
||||||
:dnskeys_min_count,
|
:dnskeys_min_count,
|
||||||
:dnskeys_max_count,
|
:dnskeys_max_count,
|
||||||
|
|
|
@ -41,7 +41,6 @@ class Contact < ActiveRecord::Base
|
||||||
validate :val_country_code
|
validate :val_country_code
|
||||||
|
|
||||||
after_initialize do
|
after_initialize do
|
||||||
self.statuses = [] if statuses.nil?
|
|
||||||
self.status_notes = {} if status_notes.nil?
|
self.status_notes = {} if status_notes.nil?
|
||||||
self.ident_updated_at = Time.zone.now if new_record? && ident_updated_at.blank?
|
self.ident_updated_at = Time.zone.now if new_record? && ident_updated_at.blank?
|
||||||
end
|
end
|
||||||
|
@ -175,20 +174,28 @@ class Contact < ActiveRecord::Base
|
||||||
')
|
')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# To leave only new ones we need to check
|
||||||
|
# if contact was at any time used in domain.
|
||||||
|
# This can be checked by domain history.
|
||||||
|
# This can be checked by saved relations in children attribute
|
||||||
def destroy_orphans
|
def destroy_orphans
|
||||||
STDOUT << "#{Time.zone.now.utc} - Destroying orphaned contacts\n" unless Rails.env.test?
|
STDOUT << "#{Time.zone.now.utc} - Destroying orphaned contacts\n" unless Rails.env.test?
|
||||||
|
|
||||||
orphans = find_orphans
|
counter = Counter.new
|
||||||
|
find_orphans.find_each do |contact|
|
||||||
unless Rails.env.test?
|
ver_scope = []
|
||||||
orphans.each do |m|
|
%w(admin_contacts tech_contacts registrant).each do |type|
|
||||||
STDOUT << "#{Time.zone.now.utc} Contact.destroy_orphans: ##{m.id} (#{m.name})\n"
|
ver_scope << "(children->'#{type}')::jsonb <@ json_build_array(#{contact.id})::jsonb"
|
||||||
end
|
end
|
||||||
|
next if DomainVersion.where("created_at > ?", Time.now - Setting.orphans_contacts_in_months.to_i.months).where(ver_scope.join(" OR ")).any?
|
||||||
|
next if contact.domains_present?
|
||||||
|
|
||||||
|
contact.destroy
|
||||||
|
counter.next
|
||||||
|
STDOUT << "#{Time.zone.now.utc} Contact.destroy_orphans: ##{contact.id} (#{contact.name})\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
count = orphans.destroy_all.count
|
STDOUT << "#{Time.zone.now.utc} - Successfully destroyed #{counter} orphaned contacts\n" unless Rails.env.test?
|
||||||
|
|
||||||
STDOUT << "#{Time.zone.now.utc} - Successfully destroyed #{count} orphaned contacts\n" unless Rails.env.test?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def privs
|
def privs
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
= render 'setting_row', var: :admin_contacts_max_count
|
= render 'setting_row', var: :admin_contacts_max_count
|
||||||
= render 'setting_row', var: :tech_contacts_min_count
|
= render 'setting_row', var: :tech_contacts_min_count
|
||||||
= render 'setting_row', var: :tech_contacts_max_count
|
= render 'setting_row', var: :tech_contacts_max_count
|
||||||
|
= render 'setting_row', var: :orphans_contacts_in_months
|
||||||
= render 'setting_row', var: :ds_data_allowed
|
= render 'setting_row', var: :ds_data_allowed
|
||||||
= render 'setting_row', var: :key_data_allowed
|
= render 'setting_row', var: :key_data_allowed
|
||||||
= render 'setting_row', var: :dnskeys_min_count
|
= render 'setting_row', var: :dnskeys_min_count
|
||||||
|
|
|
@ -10,6 +10,7 @@ if con.present? && con.table_exists?('settings')
|
||||||
Setting.save_default(:admin_contacts_max_count, 10)
|
Setting.save_default(:admin_contacts_max_count, 10)
|
||||||
Setting.save_default(:tech_contacts_min_count, 1)
|
Setting.save_default(:tech_contacts_min_count, 1)
|
||||||
Setting.save_default(:tech_contacts_max_count, 10)
|
Setting.save_default(:tech_contacts_max_count, 10)
|
||||||
|
Setting.save_default(:orphans_contacts_in_months, 6)
|
||||||
Setting.save_default(:expire_pending_confirmation, 48)
|
Setting.save_default(:expire_pending_confirmation, 48)
|
||||||
|
|
||||||
Setting.save_default(:ds_digest_type, 2)
|
Setting.save_default(:ds_digest_type, 2)
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class ChangeContactStatusesDefault < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
change_column_default :contacts, :statuses, []
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue