mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 10:16:01 +02:00
Resolve merge errors
This commit is contained in:
commit
73e9dd6870
817 changed files with 16875 additions and 17443 deletions
|
@ -1,149 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "action_view"
|
||||
require "action_controller"
|
||||
require "action_controller/log_subscriber"
|
||||
|
||||
module ActionController
|
||||
# API Controller is a lightweight version of <tt>ActionController::Base</tt>,
|
||||
# created for applications that don't require all functionalities that a complete
|
||||
# \Rails controller provides, allowing you to create controllers with just the
|
||||
# features that you need for API only applications.
|
||||
#
|
||||
# An API Controller is different from a normal controller in the sense that
|
||||
# by default it doesn't include a number of features that are usually required
|
||||
# by browser access only: layouts and templates rendering, cookies, sessions,
|
||||
# flash, assets, and so on. This makes the entire controller stack thinner,
|
||||
# suitable for API applications. It doesn't mean you won't have such
|
||||
# features if you need them: they're all available for you to include in
|
||||
# your application, they're just not part of the default API controller stack.
|
||||
#
|
||||
# Normally, +ApplicationController+ is the only controller that inherits from
|
||||
# <tt>ActionController::API</tt>. All other controllers in turn inherit from
|
||||
# +ApplicationController+.
|
||||
#
|
||||
# A sample controller could look like this:
|
||||
#
|
||||
# class PostsController < ApplicationController
|
||||
# def index
|
||||
# posts = Post.all
|
||||
# render json: posts
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# Request, response, and parameters objects all work the exact same way as
|
||||
# <tt>ActionController::Base</tt>.
|
||||
#
|
||||
# == Renders
|
||||
#
|
||||
# The default API Controller stack includes all renderers, which means you
|
||||
# can use <tt>render :json</tt> and brothers freely in your controllers. Keep
|
||||
# in mind that templates are not going to be rendered, so you need to ensure
|
||||
# your controller is calling either <tt>render</tt> or <tt>redirect_to</tt> in
|
||||
# all actions, otherwise it will return 204 No Content.
|
||||
#
|
||||
# def show
|
||||
# post = Post.find(params[:id])
|
||||
# render json: post
|
||||
# end
|
||||
#
|
||||
# == Redirects
|
||||
#
|
||||
# Redirects are used to move from one action to another. You can use the
|
||||
# <tt>redirect_to</tt> method in your controllers in the same way as in
|
||||
# <tt>ActionController::Base</tt>. For example:
|
||||
#
|
||||
# def create
|
||||
# redirect_to root_url and return if not_authorized?
|
||||
# # do stuff here
|
||||
# end
|
||||
#
|
||||
# == Adding New Behavior
|
||||
#
|
||||
# In some scenarios you may want to add back some functionality provided by
|
||||
# <tt>ActionController::Base</tt> that is not present by default in
|
||||
# <tt>ActionController::API</tt>, for instance <tt>MimeResponds</tt>. This
|
||||
# module gives you the <tt>respond_to</tt> method. Adding it is quite simple,
|
||||
# you just need to include the module in a specific controller or in
|
||||
# +ApplicationController+ in case you want it available in your entire
|
||||
# application:
|
||||
#
|
||||
# class ApplicationController < ActionController::API
|
||||
# include ActionController::MimeResponds
|
||||
# end
|
||||
#
|
||||
# class PostsController < ApplicationController
|
||||
# def index
|
||||
# posts = Post.all
|
||||
#
|
||||
# respond_to do |format|
|
||||
# format.json { render json: posts }
|
||||
# format.xml { render xml: posts }
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# Make sure to check the modules included in <tt>ActionController::Base</tt>
|
||||
# if you want to use any other functionality that is not provided
|
||||
# by <tt>ActionController::API</tt> out of the box.
|
||||
class API < Metal
|
||||
abstract!
|
||||
|
||||
# Shortcut helper that returns all the ActionController::API modules except
|
||||
# the ones passed as arguments:
|
||||
#
|
||||
# class MyAPIBaseController < ActionController::Metal
|
||||
# ActionController::API.without_modules(:ForceSSL, :UrlFor).each do |left|
|
||||
# include left
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# This gives better control over what you want to exclude and makes it easier
|
||||
# to create an API controller class, instead of listing the modules required
|
||||
# manually.
|
||||
def self.without_modules(*modules)
|
||||
modules = modules.map do |m|
|
||||
m.is_a?(Symbol) ? ActionController.const_get(m) : m
|
||||
end
|
||||
|
||||
MODULES - modules
|
||||
end
|
||||
|
||||
MODULES = [
|
||||
AbstractController::Rendering,
|
||||
|
||||
UrlFor,
|
||||
Redirecting,
|
||||
ApiRendering,
|
||||
Renderers::All,
|
||||
ConditionalGet,
|
||||
BasicImplicitRender,
|
||||
StrongParameters,
|
||||
|
||||
ForceSSL,
|
||||
DataStreaming,
|
||||
|
||||
# Before callbacks should also be executed as early as possible, so
|
||||
# also include them at the bottom.
|
||||
AbstractController::Callbacks,
|
||||
|
||||
# Append rescue at the bottom to wrap as much as possible.
|
||||
Rescue,
|
||||
|
||||
# Add instrumentations hooks at the bottom, to ensure they instrument
|
||||
# all the methods properly.
|
||||
Instrumentation,
|
||||
|
||||
# Params wrapper should come before instrumentation so they are
|
||||
# properly showed in logs
|
||||
ParamsWrapper
|
||||
]
|
||||
|
||||
MODULES.each do |mod|
|
||||
include mod
|
||||
end
|
||||
|
||||
ActiveSupport.run_load_hooks(:action_controller_api, self)
|
||||
ActiveSupport.run_load_hooks(:action_controller, self)
|
||||
end
|
||||
end
|
|
@ -1,16 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module ActionController
|
||||
module ApiRendering
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
include Rendering
|
||||
end
|
||||
|
||||
def render_to_body(options = {})
|
||||
_process_options(options)
|
||||
super
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,13 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module ActionController
|
||||
module BasicImplicitRender # :nodoc:
|
||||
def send_action(method, *args)
|
||||
super.tap { default_render unless performed? }
|
||||
end
|
||||
|
||||
def default_render(*args)
|
||||
head :no_content
|
||||
end
|
||||
end
|
||||
end
|
61
lib/deserializers/xml/contact.rb
Normal file
61
lib/deserializers/xml/contact.rb
Normal file
|
@ -0,0 +1,61 @@
|
|||
module Deserializers
|
||||
module Xml
|
||||
class Contact
|
||||
attr_reader :frame
|
||||
|
||||
def initialize(frame)
|
||||
@frame = frame
|
||||
end
|
||||
|
||||
def call
|
||||
attributes = {
|
||||
name: if_present('postalInfo name'),
|
||||
org_name: if_present('postalInfo org'),
|
||||
email: if_present('email'),
|
||||
fax: if_present('fax'),
|
||||
phone: if_present('voice'),
|
||||
|
||||
# Address fields
|
||||
city: if_present('postalInfo addr city'),
|
||||
zip: if_present('postalInfo addr pc'),
|
||||
street: if_present('postalInfo addr street'),
|
||||
state: if_present('postalInfo addr sp'),
|
||||
country_code: if_present('postalInfo addr cc'),
|
||||
|
||||
# Auth info
|
||||
auth_info: if_present('authInfo pw'),
|
||||
|
||||
# statuses
|
||||
statuses_to_add: statuses_to_add,
|
||||
statuses_to_remove: statuses_to_remove,
|
||||
}
|
||||
|
||||
attributes.compact
|
||||
end
|
||||
|
||||
def if_present(css_path)
|
||||
return if frame.css(css_path).blank?
|
||||
|
||||
frame.css(css_path).text
|
||||
end
|
||||
|
||||
def statuses_to_add
|
||||
statuses_frame = frame.css('add')
|
||||
return if statuses_frame.blank?
|
||||
|
||||
statuses_frame.css('status').map do |status|
|
||||
status['s']
|
||||
end
|
||||
end
|
||||
|
||||
def statuses_to_remove
|
||||
statuses_frame = frame.css('rem')
|
||||
return if statuses_frame.blank?
|
||||
|
||||
statuses_frame.css('status').map do |status|
|
||||
status['s']
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
27
lib/deserializers/xml/contact_update.rb
Normal file
27
lib/deserializers/xml/contact_update.rb
Normal file
|
@ -0,0 +1,27 @@
|
|||
require 'deserializers/xml/legal_document'
|
||||
require 'deserializers/xml/ident'
|
||||
require 'deserializers/xml/contact'
|
||||
|
||||
module Deserializers
|
||||
module Xml
|
||||
class ContactUpdate
|
||||
attr_reader :frame
|
||||
|
||||
def initialize(frame)
|
||||
@frame = frame
|
||||
end
|
||||
|
||||
def contact
|
||||
@contact ||= ::Deserializers::Xml::Contact.new(frame).call
|
||||
end
|
||||
|
||||
def ident
|
||||
@ident ||= ::Deserializers::Xml::Ident.new(frame).call
|
||||
end
|
||||
|
||||
def legal_document
|
||||
@legal_document ||= ::Deserializers::Xml::LegalDocument.new(frame).call
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
34
lib/deserializers/xml/ident.rb
Normal file
34
lib/deserializers/xml/ident.rb
Normal file
|
@ -0,0 +1,34 @@
|
|||
module Deserializers
|
||||
module Xml
|
||||
class Ident
|
||||
attr_reader :frame
|
||||
|
||||
def initialize(frame)
|
||||
@frame = frame.css('ident').first
|
||||
end
|
||||
|
||||
def call
|
||||
if valid?
|
||||
{
|
||||
ident: frame.text,
|
||||
ident_type: frame.attr('type'),
|
||||
ident_country_code: frame.attr('cc'),
|
||||
}
|
||||
else
|
||||
{}
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def valid?
|
||||
return false if frame.blank?
|
||||
return false if frame.try('text').blank?
|
||||
return false if frame.attr('type').blank?
|
||||
return false if frame.attr('cc').blank?
|
||||
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
22
lib/deserializers/xml/legal_document.rb
Normal file
22
lib/deserializers/xml/legal_document.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
module Deserializers
|
||||
module Xml
|
||||
# Given a nokogiri frame, extract information about legal document from it.
|
||||
class LegalDocument
|
||||
attr_reader :frame
|
||||
|
||||
def initialize(frame)
|
||||
@frame = frame
|
||||
end
|
||||
|
||||
def call
|
||||
ld = frame.css('legalDocument').first
|
||||
return unless ld
|
||||
|
||||
{
|
||||
body: ld.text,
|
||||
type: ld['type'],
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -15,7 +15,7 @@ class EppConstraint
|
|||
request.params[:nokogiri_frame] ||= Nokogiri::XML(request.params[:raw_frame] || request.params[:frame])
|
||||
request.params[:parsed_frame] ||= request.params[:nokogiri_frame].dup.remove_namespaces!
|
||||
|
||||
unless [:keyrelay, :poll, :session, :not_found].include?(@type)
|
||||
unless %i[poll session].include?(@type)
|
||||
element = "//#{@type}:#{request.params[:action]}"
|
||||
return false if request.params[:nokogiri_frame].xpath("#{element}", OBJECT_TYPES[@type]).none?
|
||||
end
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# Store console and rake changes in versions
|
||||
if defined?(::Rails::Console)
|
||||
PaperTrail.whodunnit = "console-#{`whoami`.strip}"
|
||||
PaperTrail.request.whodunnit = "console-#{`whoami`.strip}"
|
||||
elsif File.basename($PROGRAM_NAME) == 'rake'
|
||||
# rake username does not work when spring enabled
|
||||
PaperTrail.whodunnit = "rake-#{`whoami`.strip} #{ARGV.join ' '}"
|
||||
PaperTrail.request.whodunnit = "rake-#{`whoami`.strip} #{ARGV.join ' '}"
|
||||
end
|
||||
|
||||
class PaperSession
|
40
lib/gem_monkey_patches/ransack.rb
Normal file
40
lib/gem_monkey_patches/ransack.rb
Normal file
|
@ -0,0 +1,40 @@
|
|||
# A custom initializer that enables sorting via custom scopes in Ransack (like the same feature in MetaSearch)
|
||||
|
||||
module Ransack
|
||||
module Adapters
|
||||
module ActiveRecord
|
||||
class Context < ::Ransack::Context
|
||||
|
||||
# Allows for sorting by custom scopes
|
||||
#
|
||||
#
|
||||
# Define your custom scopes in your model, e. g. sort_by_title_asc and sort_by_title_desc
|
||||
# (The scopes would sort by some calculated column or a column added via some crazy join, etc.)
|
||||
#
|
||||
# In your sort links refer to the scopes like to standard fields, e. g.
|
||||
# <%= sort_link(@q, :title, 'Crazy calculated title') %>
|
||||
def evaluate(search, opts = {})
|
||||
viz = Visitor.new
|
||||
relation = @object.where(viz.accept(search.base))
|
||||
if search.sorts.any?
|
||||
custom_scopes = search.sorts.select do |s|
|
||||
custom_scope_name = :"sort_by_#{s.name}_#{s.dir}"
|
||||
relation.respond_to?(custom_scope_name)
|
||||
end
|
||||
attribute_scopes = search.sorts - custom_scopes
|
||||
|
||||
relation = relation.except(:order)
|
||||
|
||||
custom_scopes.each do |s|
|
||||
custom_scope_name = :"sort_by_#{s.name}_#{s.dir}"
|
||||
relation = relation.public_send(custom_scope_name)
|
||||
end
|
||||
|
||||
relation = relation.reorder(viz.accept(attribute_scopes)) if attribute_scopes.any?
|
||||
end
|
||||
opts[:distinct] ? relation.distinct : relation
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,3 +0,0 @@
|
|||
require_relative 'action_controller/metal/basic_implicit_render'
|
||||
require_relative 'action_controller/api/api_rendering'
|
||||
require_relative 'action_controller/api'
|
|
@ -23,9 +23,6 @@
|
|||
<!-- EPP protocol extension: DNSSEC -->
|
||||
<import namespace="urn:ietf:params:xml:ns:secDNS-1.1"
|
||||
schemaLocation="lib/schemas/secDNS-1.1.xsd"/>
|
||||
<!-- EPP protocol extension: DNSSEC keyrelay -->
|
||||
<import namespace="urn:ietf:params:xml:ns:keyrelay-1.0"
|
||||
schemaLocation="lib/schemas/keyrelay-1.0.xsd"/>
|
||||
<import namespace="urn:ietf:params:xml:ns:host-1.0"
|
||||
schemaLocation="lib/schemas/host-1.0.xsd"/>
|
||||
<!-- EPP protocol extension: .ee specific -->
|
||||
|
|
|
@ -23,9 +23,6 @@
|
|||
<!-- EPP protocol extension: DNSSEC -->
|
||||
<import namespace="urn:ietf:params:xml:ns:secDNS-1.1"
|
||||
schemaLocation="lib/schemas/secDNS-1.1.xsd"/>
|
||||
<!-- EPP protocol extension: DNSSEC keyrelay -->
|
||||
<import namespace="urn:ietf:params:xml:ns:keyrelay-1.0"
|
||||
schemaLocation="lib/schemas/keyrelay-1.0.xsd"/>
|
||||
<import namespace="urn:ietf:params:xml:ns:host-1.0"
|
||||
schemaLocation="lib/schemas/host-1.0.xsd"/>
|
||||
<!-- EPP protocol extension: .ee specific -->
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<schema targetNamespace="urn:ietf:params:xml:ns:keyrelay-1.0"
|
||||
xmlns:keyrelay="urn:ietf:params:xml:ns:keyrelay-1.0"
|
||||
xmlns:epp="https://epp.tld.ee/schema/epp-ee-1.0.xsd"
|
||||
xmlns:eppcom="urn:ietf:params:xml:ns:eppcom-1.0"
|
||||
xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1"
|
||||
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"
|
||||
xmlns="http://www.w3.org/2001/XMLSchema"
|
||||
elementFormDefault="qualified">
|
||||
|
||||
<annotation>
|
||||
<documentation>
|
||||
Extensible Provisioning Protocol v1.0 protocol
|
||||
extension schema for relaying DNSSEC key material.
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<import namespace="https://epp.tld.ee/schema/epp-ee-1.0.xsd"/>
|
||||
<import namespace="urn:ietf:params:xml:ns:eppcom-1.0"/>
|
||||
<import namespace="urn:ietf:params:xml:ns:secDNS-1.1"/>
|
||||
<import namespace="urn:ietf:params:xml:ns:domain-1.0"/>
|
||||
|
||||
<element name="keyRelayData" type="keyrelay:keyRelayDataType" />
|
||||
<element name="infData" type="keyrelay:infDataType" />
|
||||
<element name="create" type="keyrelay:createType" />
|
||||
|
||||
<complexType name="createType">
|
||||
<sequence>
|
||||
<element name="name" type="eppcom:labelType"/>
|
||||
<!-- <element name="authInfo" type="domain:authInfoType"/> -->
|
||||
<element name="keyRelayData" type="keyrelay:keyRelayDataType"
|
||||
maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
|
||||
<complexType name="infDataType">
|
||||
<sequence>
|
||||
<element name="name" type="eppcom:labelType"/>
|
||||
<!-- <element name="authInfo" type="domain:authInfoType"/> -->
|
||||
<element name="keyRelayData" type="keyrelay:keyRelayDataType"
|
||||
maxOccurs="unbounded"/>
|
||||
<element name="crDate" type="dateTime"/>
|
||||
<element name="reID" type="eppcom:clIDType" />
|
||||
<element name="acID" type="eppcom:clIDType" />
|
||||
</sequence>
|
||||
</complexType>
|
||||
|
||||
<complexType name="keyRelayDataType">
|
||||
<sequence>
|
||||
<element name="keyData" type="secDNS:keyDataType" />
|
||||
<element name="expiry" type="keyrelay:keyRelayExpiryType"
|
||||
minOccurs="0" />
|
||||
</sequence>
|
||||
</complexType>
|
||||
|
||||
<complexType name="keyRelayExpiryType">
|
||||
<choice>
|
||||
<element name="absolute" type="dateTime" />
|
||||
<element name="relative" type="duration" />
|
||||
</choice>
|
||||
</complexType>
|
||||
</schema>
|
|
@ -32,9 +32,6 @@ module Serializers
|
|||
period_unit: domain.period_unit,
|
||||
creator_str: domain.creator_str,
|
||||
updator_str: domain.updator_str,
|
||||
legacy_id: domain.legacy_id,
|
||||
legacy_registrar_id: domain.legacy_registrar_id,
|
||||
legacy_registrant_id: domain.legacy_registrant_id,
|
||||
outzone_at: domain.outzone_at,
|
||||
delete_date: domain.delete_date,
|
||||
registrant_verification_asked_at: domain.registrant_verification_asked_at,
|
||||
|
@ -45,11 +42,23 @@ module Serializers
|
|||
locked_by_registrant_at: domain.locked_by_registrant_at,
|
||||
status_notes: domain.status_notes,
|
||||
nameservers: nameservers,
|
||||
dnssec_keys: dnssec_keys,
|
||||
dnssec_changed_at: dnssec_updated_at,
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def dnssec_keys
|
||||
domain.dnskeys.map do |key|
|
||||
"#{key.flags} #{key.protocol} #{key.alg} #{key.public_key}"
|
||||
end
|
||||
end
|
||||
|
||||
def dnssec_updated_at
|
||||
domain.dnskeys.order(updated_at: :desc).select(:updated_at).first
|
||||
end
|
||||
|
||||
def contacts(type)
|
||||
contact_pool = begin
|
||||
if type == :tech
|
||||
|
@ -61,7 +70,7 @@ module Serializers
|
|||
|
||||
array_of_contacts = []
|
||||
contact_pool.map do |contact|
|
||||
array_of_contacts.push(name: contact.name, id: contact.uuid)
|
||||
array_of_contacts.push(name: contact.name, id: contact.uuid, email: contact.email)
|
||||
end
|
||||
|
||||
array_of_contacts
|
||||
|
|
|
@ -1,117 +0,0 @@
|
|||
namespace :convert do
|
||||
desc 'Convert punycodes to unicode'
|
||||
task punycode: :environment do
|
||||
start = Time.zone.now.to_f
|
||||
puts "-----> Convert domain punycodes to unicode..."
|
||||
count = 0
|
||||
Domain.find_each(:batch_size => 1000) do |x|
|
||||
old_name = x.name
|
||||
if old_name != SimpleIDN.to_unicode(x.name.strip.downcase)
|
||||
x.update_column(:name, (SimpleIDN.to_unicode(x.name.strip.downcase)))
|
||||
x.update_column(:name_puny, (SimpleIDN.to_ascii(x.name.strip.downcase)))
|
||||
count += 1
|
||||
puts "Domain #{x.id} changed from #{old_name} to #{SimpleIDN.to_unicode(old_name)} "
|
||||
end
|
||||
end
|
||||
puts "-----> all done in #{(Time.zone.now.to_f - start).round(2)} seconds. #{count} domains changed."
|
||||
end
|
||||
|
||||
desc 'Convert punycodes in history to unicode'
|
||||
task history_punycode: :environment do
|
||||
DomainVersion.find_each do |d|
|
||||
if obj = d.object
|
||||
obj["name"] = SimpleIDN.to_unicode(obj["name"])
|
||||
obj["name_puny"] = SimpleIDN.to_ascii(obj["name_puny"])
|
||||
d.object = obj
|
||||
end
|
||||
if (obj_c = d.object_changes).present?
|
||||
obj_c["name"].map!{|e| e ? SimpleIDN.to_unicode(e) : e } if obj_c["name"]
|
||||
obj_c["name_puny"].map!{|e| e ? SimpleIDN.to_ascii(e) : e } if obj_c["name_puny"]
|
||||
d.object_changes = obj_c
|
||||
end
|
||||
d.save!
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
desc 'Contact Address Country Code Upcase'
|
||||
task country_code_upcase: :environment do
|
||||
count = 0
|
||||
Contact.find_each do |c|
|
||||
if c.country_code.present? && c.country_code != c.country_code.upcase
|
||||
c.country_code = c.country_code.upcase
|
||||
c.update_columns(country_code: c.country_code.upcase)
|
||||
|
||||
count +=1
|
||||
puts "#{count} contacts has been changed" if count % 1000 == 0
|
||||
end
|
||||
end
|
||||
puts "Contacts change has been finished. Starting ContactVersions"
|
||||
|
||||
count = 0
|
||||
ContactVersion.find_each do |c|
|
||||
if (if_object = (c.object && c.object["country_code"].present? && c.object["country_code"] != c.object["country_code"].upcase)) ||
|
||||
(if_changes = (c.object_changes && c.object_changes["country_code"].present? && c.object_changes["country_code"] != c.object_changes["country_code"].map{|e|e.try(:upcase)}))
|
||||
|
||||
if if_object
|
||||
h = c.object
|
||||
h["country_code"] = h["country_code"].try(:upcase)
|
||||
c.object = h
|
||||
end
|
||||
|
||||
if if_changes
|
||||
h = c.object_changes
|
||||
h["country_code"] = h["country_code"].map{|e|e.try(:upcase)}
|
||||
c.object_changes = h
|
||||
end
|
||||
c.update_columns(object: c.object, object_changes: c.object_changes)
|
||||
|
||||
count +=1
|
||||
puts "#{count} contact histories has been changed" if count % 1000 == 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Convert nameservers hostname and hostname_puny'
|
||||
task nameserves_hostname: :environment do
|
||||
|
||||
start = Time.zone.now.to_f
|
||||
count = 0
|
||||
puts '-----> Converting hostnames...'
|
||||
|
||||
Nameserver.find_each(:batch_size => 1000) do |ns|
|
||||
ns.hostname = SimpleIDN.to_unicode(ns.hostname)
|
||||
ns.hostname_puny = SimpleIDN.to_ascii(ns.hostname_puny)
|
||||
ns.save validate: false
|
||||
count += 1
|
||||
puts "-----> Converted #{count} nameservers" if count % 1000 == 0
|
||||
end
|
||||
puts "-----> Converted #{count} nameservers #{(Time.zone.now.to_f - start).round(2)} seconds"
|
||||
|
||||
end
|
||||
|
||||
desc 'Convert nameservers history hostname'
|
||||
task nameserves_history_hostname: :environment do
|
||||
|
||||
start = Time.zone.now.to_f
|
||||
count = 0
|
||||
puts '-----> Converting hostnames history...'
|
||||
|
||||
NameserverVersion.find_each do |ns|
|
||||
if obj = ns.object
|
||||
obj["hostname"] = SimpleIDN.to_unicode(obj["hostname"])
|
||||
ns.object = obj
|
||||
end
|
||||
|
||||
if (obj_c = ns.object_changes).present?
|
||||
obj_c["name"].map!{|e| e ? SimpleIDN.to_unicode(e) : e } if obj_c["hostname"]
|
||||
ns.object_changes = obj_c
|
||||
end
|
||||
count += 1
|
||||
ns.save!
|
||||
end
|
||||
puts "-----> Converted #{count} history rows #{(Time.zone.now.to_f - start).round(2)} seconds"
|
||||
end
|
||||
|
||||
end
|
||||
|
0
lib/tasks/data_migrations/.keep
Normal file
0
lib/tasks/data_migrations/.keep
Normal file
|
@ -1,16 +0,0 @@
|
|||
namespace :data_migrations do
|
||||
task convert_domain_delete_date: :environment do
|
||||
processed_domain_count = 0
|
||||
|
||||
Domain.transaction do
|
||||
Domain.find_each do |domain|
|
||||
next unless domain.delete_date
|
||||
|
||||
domain.update_columns(delete_date: domain.delete_date + 1.day)
|
||||
processed_domain_count += 1
|
||||
end
|
||||
end
|
||||
|
||||
puts "Domains processed: #{processed_domain_count}"
|
||||
end
|
||||
end
|
|
@ -1,16 +0,0 @@
|
|||
namespace :data_migrations do
|
||||
task regenerate_registrar_reference_numbers: [:environment] do
|
||||
processed_registrar_count = 0
|
||||
|
||||
Registrar.transaction do
|
||||
Registrar.all.each do |registrar|
|
||||
next unless registrar.reference_no.start_with?('RF')
|
||||
|
||||
registrar.update_columns(reference_no: Billing::ReferenceNo.generate)
|
||||
processed_registrar_count += 1
|
||||
end
|
||||
end
|
||||
|
||||
puts "Registrars processed: #{processed_registrar_count}"
|
||||
end
|
||||
end
|
73
lib/tasks/dev/create_bank_transactions/bank_transactions.xml
Normal file
73
lib/tasks/dev/create_bank_transactions/bank_transactions.xml
Normal file
|
@ -0,0 +1,73 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03">
|
||||
<CstmrCdtTrfInitn>
|
||||
<GrpHdr>
|
||||
<MsgId>populated by rake task</MsgId>
|
||||
<CreDtTm>2019-07-28T10:00:00</CreDtTm>
|
||||
<NbOfTxs>1</NbOfTxs>
|
||||
<!-- Amount of all transactions; acts as a checksum -->
|
||||
<CtrlSum>0.1</CtrlSum>
|
||||
<InitgPty>
|
||||
<Nm>ABC Corporation</Nm>
|
||||
</InitgPty>
|
||||
</GrpHdr>
|
||||
<PmtInf>
|
||||
<PmtInfId>test3</PmtInfId>
|
||||
<PmtMtd>TRF</PmtMtd>
|
||||
<BtchBookg>false</BtchBookg>
|
||||
<NbOfTxs>1</NbOfTxs>
|
||||
<ReqdExctnDt>2019-07-28</ReqdExctnDt>
|
||||
<Dbtr>
|
||||
<Nm>test</Nm>
|
||||
</Dbtr>
|
||||
<DbtrAcct>
|
||||
<Id>
|
||||
<IBAN>populated by rake task</IBAN>
|
||||
</Id>
|
||||
<Ccy>EUR</Ccy>
|
||||
</DbtrAcct>
|
||||
<DbtrAgt>
|
||||
<FinInstnId>
|
||||
<BIC>LHVBEE22</BIC>
|
||||
</FinInstnId>
|
||||
</DbtrAgt>
|
||||
<CdtTrfTxInf>
|
||||
<PmtId>
|
||||
<InstrId>ABC/090928/CCT001/01</InstrId>
|
||||
<EndToEndId>ABC/4562/2009-09-08</EndToEndId>
|
||||
</PmtId>
|
||||
<Amt>
|
||||
<!-- Transaction amount. Use the smallest amount possible in dev mode, since account balance is not infinite -->
|
||||
<InstdAmt Ccy="EUR">0.1</InstdAmt>
|
||||
</Amt>
|
||||
<ChrgBr>SHAR</ChrgBr>
|
||||
<CdtrAgt>
|
||||
<FinInstnId>
|
||||
<BIC>LHVBEE22</BIC>
|
||||
</FinInstnId>
|
||||
</CdtrAgt>
|
||||
<Cdtr>
|
||||
<Nm>DEF Electronics</Nm>
|
||||
<PstlAdr>
|
||||
<AdrLine>Corn Exchange 5th Floor</AdrLine>
|
||||
</PstlAdr>
|
||||
</Cdtr>
|
||||
<CdtrAcct>
|
||||
<Id>
|
||||
<IBAN>populated by rake task</IBAN>
|
||||
</Id>
|
||||
</CdtrAcct>
|
||||
<RmtInf>
|
||||
<!-- payment description -->
|
||||
<Ustrd>1</Ustrd>
|
||||
<Strd>
|
||||
<CdtrRefInf>
|
||||
<!-- payment reference number -->
|
||||
<Ref>13</Ref>
|
||||
</CdtrRefInf>
|
||||
</Strd>
|
||||
</RmtInf>
|
||||
</CdtTrfTxInf>
|
||||
</PmtInf>
|
||||
</CstmrCdtTrfInitn>
|
||||
</Document>
|
|
@ -0,0 +1,38 @@
|
|||
namespace :dev do
|
||||
task create_bank_transactions: :environment do
|
||||
remitter_iban = ENV['remitter_iban']
|
||||
beneficiary_iban = Setting.registry_iban
|
||||
|
||||
keystore = OpenSSL::PKCS12.new(File.read(ENV['lhv_p12_keystore']), ENV['lhv_keystore_password'])
|
||||
key = keystore.key
|
||||
cert = keystore.certificate
|
||||
|
||||
api_base_uri = URI.parse('https://testconnect.lhv.eu/connect-prelive')
|
||||
request_headers = { 'content-type' => 'application/xml' }
|
||||
|
||||
request_xml = File.binread(File.join(__dir__, 'bank_transactions.xml'))
|
||||
request_xml_doc = Nokogiri::XML(request_xml)
|
||||
request_xml_doc.at_css('CstmrCdtTrfInitn > GrpHdr > MsgId').content = SecureRandom.hex
|
||||
request_xml_doc.at_css('CstmrCdtTrfInitn > PmtInf > DbtrAcct > Id > IBAN')
|
||||
.content = remitter_iban
|
||||
request_xml_doc.at_css('CstmrCdtTrfInitn > PmtInf > CdtTrfTxInf > CdtrAcct > Id > IBAN')
|
||||
.content = beneficiary_iban
|
||||
request_body = request_xml_doc.to_xml
|
||||
|
||||
http = Net::HTTP.new(api_base_uri.host, api_base_uri.port)
|
||||
http.use_ssl = api_base_uri.is_a?(URI::HTTPS)
|
||||
http.cert = cert
|
||||
http.key = key
|
||||
http.ca_file = ENV['lhv_ca_file']
|
||||
|
||||
http.start do
|
||||
response = http.post(api_base_uri.path + '/payment', request_body, request_headers)
|
||||
|
||||
if response.is_a?(Net::HTTPSuccess)
|
||||
puts 'Success'
|
||||
else
|
||||
puts 'Failure'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,783 +0,0 @@
|
|||
namespace :import do
|
||||
# README
|
||||
#
|
||||
# 1) ESTABLISH CONNECTION TO FRED DATABASE
|
||||
# ----------------------------------------
|
||||
#
|
||||
# Add 'fred' database connection settings to config/database.yml
|
||||
# Example config:
|
||||
#
|
||||
# fred:
|
||||
# host: localhost
|
||||
# adapter: postgresql
|
||||
# encoding: unicode
|
||||
# pool: 5
|
||||
# username: fred
|
||||
# password: fred
|
||||
#
|
||||
# Verify you have correctly connected to fred database:
|
||||
# Open Rails console:
|
||||
#
|
||||
# cd your_registry_deploy_path/current/
|
||||
# RAILS_ENV=production bundle exec rails c
|
||||
# in console: Legacy::Contact.last
|
||||
# in console: exit
|
||||
#
|
||||
# In console you should get Last Legacy::Contact object.
|
||||
# If you get any errors, scroll up and read first lines
|
||||
# to figure out what went wrong to connect to fred database.
|
||||
#
|
||||
#
|
||||
# 2) START IMPORT
|
||||
# ---------------
|
||||
#
|
||||
# Import scrip does not write anything to fred database.
|
||||
# Script is implemented this way, you can run it multiple times
|
||||
# in case you need it. However already imported object are
|
||||
# not reimported, thus if some object has been updated meanwhile
|
||||
# in fred database, those updates will be missed and thous should
|
||||
# be carried over manually. All new object in fred will be
|
||||
# imported in multiple import script runs.
|
||||
#
|
||||
# Start all import:
|
||||
#
|
||||
# cd your_registry_deploy_path/current/
|
||||
# RAILS_ENV=production bundle exec rails import:all
|
||||
#
|
||||
# If you wish to import one by one, please follow individual import order
|
||||
# from task 'Import all' tasks in this script.
|
||||
|
||||
desc 'Import all'
|
||||
task all: :environment do
|
||||
Rake::Task['import:registrars'].invoke
|
||||
Rake::Task['import:users'].invoke
|
||||
Rake::Task['import:contacts'].invoke
|
||||
Rake::Task['import:reserved'].invoke
|
||||
Rake::Task['import:domains'].invoke
|
||||
Rake::Task['import:zones'].invoke
|
||||
end
|
||||
|
||||
desc 'Import registrars'
|
||||
task registrars: :environment do
|
||||
start = Time.zone.now.to_f
|
||||
puts '-----> Importing registrars...'
|
||||
|
||||
registrars = []
|
||||
existing_ids = Registrar.pluck(:legacy_id)
|
||||
user = "rake-#{`whoami`.strip} #{ARGV.join ' '}"
|
||||
count = 0
|
||||
|
||||
Legacy::Registrar.all.each do |x|
|
||||
next if existing_ids.include?(x.id)
|
||||
count += 1
|
||||
|
||||
registrars << Registrar.new({
|
||||
name: x.organization.try(:strip).presence || x.name.try(:strip).presence || x.handle.try(:strip).presence,
|
||||
reg_no: x.ico.try(:strip),
|
||||
vat_no: x.dic.try(:strip),
|
||||
phone: x.telephone.try(:strip),
|
||||
email: x.email.try(:strip),
|
||||
billing_email: x.billing_address.try(:strip),
|
||||
country_code: x.country.try(:strip),
|
||||
state: x.stateorprovince.try(:strip),
|
||||
city: x.city.try(:strip),
|
||||
street: x.street1.try(:strip),
|
||||
zip: x.postalcode.try(:strip),
|
||||
url: x.url.try(:strip),
|
||||
accounting_customer_code: x.directo_handle.try(:strip),
|
||||
legacy_id: x.id,
|
||||
creator_str: user,
|
||||
updator_str: user,
|
||||
code: x.handle.upcase
|
||||
})
|
||||
end
|
||||
|
||||
Registrar.import registrars, validate: false
|
||||
|
||||
puts "-----> Generating reference numbers"
|
||||
|
||||
Registrar.all.each do |x|
|
||||
x.save(validate: false)
|
||||
end
|
||||
|
||||
puts "-----> Creating accounts numbers"
|
||||
|
||||
Registrar.all.each do |x|
|
||||
next if x.cash_account
|
||||
x.accounts.create(account_type: Account::CASH, currency: 'EUR')
|
||||
x.save(validate: false)
|
||||
|
||||
lr = Legacy::Registrar.find(x.legacy_id)
|
||||
x.cash_account.account_activities << AccountActivity.new({
|
||||
sum: lr.account_balance,
|
||||
currency: 'EUR',
|
||||
description: 'Transfer from legacy system'
|
||||
})
|
||||
|
||||
x.cash_account.save
|
||||
end
|
||||
|
||||
puts "-----> Imported #{count} new registrars in #{(Time.zone.now.to_f - start).round(2)} seconds"
|
||||
end
|
||||
|
||||
desc 'Import users'
|
||||
task users: :environment do
|
||||
start = Time.zone.now.to_f
|
||||
puts "-----> Importing users and IP's..."
|
||||
|
||||
id_users = []
|
||||
users = []
|
||||
ips = []
|
||||
temp = []
|
||||
|
||||
existing_ids = ApiUser.pluck(:legacy_id)
|
||||
existing_ips = WhiteIp.pluck(:ipv4)
|
||||
|
||||
Legacy::Registrar.all.each do |x|
|
||||
|
||||
x.acl.all.each do |y|
|
||||
|
||||
next if existing_ids.include?(y.id)
|
||||
|
||||
if y.try(:cert) != 'pki'
|
||||
|
||||
if y.try(:cert) == 'idkaart'
|
||||
id_users << ApiUser.new({
|
||||
username: y.try(:password) ? y.try(:password) : y.try(:password),
|
||||
plain_text_password: ('a'..'z').to_a.shuffle.first(8).join,
|
||||
identity_code: y.try(:password) ? y.try(:password) : y.try(:password),
|
||||
registrar_id: Registrar.find_by(legacy_id: x.try(:id)).try(:id),
|
||||
roles: ['billing'],
|
||||
legacy_id: y.try(:id)
|
||||
})
|
||||
else
|
||||
temp << ApiUser.new({
|
||||
username: x.handle.try(:strip),
|
||||
plain_text_password: y.try(:password) ? y.try(:password) : ('a'..'z').to_a.shuffle.first(8).join,
|
||||
registrar_id: Registrar.find_by(legacy_id: x.try(:id)).try(:id),
|
||||
roles: ['epp'],
|
||||
legacy_id: y.try(:id)
|
||||
})
|
||||
end
|
||||
end
|
||||
temp = temp.reverse!.uniq{|u| u.username }
|
||||
end
|
||||
users = temp
|
||||
|
||||
x.acl.all.each do |y|
|
||||
next if existing_ips.include?(y.ipaddr)
|
||||
if !y.ipaddr.nil? && y.ipaddr != ''
|
||||
|
||||
y.ipaddr.split(',').each do |ip|
|
||||
ips << WhiteIp.new({
|
||||
registrar_id: Registrar.find_by(legacy_id: x.try(:id)).try(:id),
|
||||
ipv4: ip,
|
||||
interfaces: ['api', 'registrar']
|
||||
})
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ApiUser.import id_users, validate: false
|
||||
ApiUser.import users, validate: false
|
||||
|
||||
if ips
|
||||
WhiteIp.import ips, validate: false
|
||||
end
|
||||
|
||||
puts "-----> Imported #{id_users.count} billing users and #{users.count} epp users"
|
||||
puts "-----> Imported #{ips.count} white IP's in #{(Time.zone.now.to_f - start).round(2)} seconds"
|
||||
|
||||
end
|
||||
|
||||
desc 'Import contacts'
|
||||
task contacts: :environment do
|
||||
start = Time.zone.now.to_f
|
||||
puts '-----> Importing contacts...'
|
||||
|
||||
# 1;"RC";"born number" # not used
|
||||
# 2;"OP";"identity card number" -> priv
|
||||
# 3;"PASS";"passwport" ->
|
||||
# 4;"ICO";"organization identification number"
|
||||
# 5;"MPSV";"social system identification" # not used
|
||||
# 6;"BIRTHDAY";"day of birth"
|
||||
|
||||
ident_type_map = {
|
||||
2 => Contact::PRIV,
|
||||
3 => Contact::PASSPORT,
|
||||
4 => Contact::ORG,
|
||||
6 => Contact::BIRTHDAY
|
||||
}
|
||||
|
||||
contact_columns = %w(
|
||||
code
|
||||
phone
|
||||
email
|
||||
fax
|
||||
created_at
|
||||
updated_at
|
||||
ident
|
||||
ident_type
|
||||
auth_info
|
||||
name
|
||||
registrar_id
|
||||
creator_str
|
||||
updator_str
|
||||
legacy_id
|
||||
street
|
||||
city
|
||||
zip
|
||||
state
|
||||
country_code
|
||||
statuses
|
||||
)
|
||||
|
||||
contacts = []
|
||||
existing_contact_ids = Contact.pluck(:legacy_id)
|
||||
count = 0
|
||||
|
||||
Legacy::Contact.includes(:object_registry, :object, object_registry: :registrar)
|
||||
.find_each(batch_size: 10000).with_index do |x, index|
|
||||
|
||||
next if existing_contact_ids.include?(x.id)
|
||||
count += 1
|
||||
|
||||
if 4 == x.ssntype
|
||||
name = x.organization.try(:strip).presence || x.name.try(:strip).presence
|
||||
else
|
||||
name = x.name.try(:strip).presence || x.organization.try(:strip).presence
|
||||
end
|
||||
|
||||
begin
|
||||
contacts << [
|
||||
x.object_registry.name.try(:strip),
|
||||
x.telephone.try(:strip),
|
||||
[x.email.try(:strip), x.notifyemail.try(:strip)].uniq.select(&:present?).join(', '),
|
||||
x.fax.try(:strip),
|
||||
x.object_registry.try(:crdate),
|
||||
x.object.read_attribute(:update).nil? ? x.object_registry.try(:crdate) : x.object.read_attribute(:update),
|
||||
x.ssn.try(:strip),
|
||||
ident_type_map[x.ssntype],
|
||||
x.object.authinfopw.try(:strip),
|
||||
name,
|
||||
Registrar.find_by(legacy_id: x.object.try(:clid)).try(:id),
|
||||
x.object_registry.try(:registrar).try(:name),
|
||||
x.object.try(:registrar).try(:name) ? x.object.try(:registrar).try(:name) : x.object_registry.try(:registrar).try(:name),
|
||||
x.id,
|
||||
[x.street1.try(:strip), x.street2.try(:strip), x.street3.try(:strip)].compact.join(", "),
|
||||
x.city.try(:strip),
|
||||
x.postalcode.try(:strip),
|
||||
x.stateorprovince.try(:strip),
|
||||
x.country.try(:strip),
|
||||
[x.object_state.try(:name), Contact::OK].compact
|
||||
]
|
||||
|
||||
if contacts.size % 10000 == 0
|
||||
Contact.import contact_columns, contacts, {validate: false, timestamps: false}
|
||||
contacts = []
|
||||
end
|
||||
rescue => e
|
||||
puts "ERROR on index #{index}"
|
||||
puts e
|
||||
end
|
||||
end
|
||||
|
||||
Contact.import contact_columns, contacts, {validate: false, timestamps: false}
|
||||
puts "-----> Imported #{count} new contacts in #{(Time.zone.now.to_f - start).round(2)} seconds"
|
||||
end
|
||||
|
||||
desc 'Import reserved'
|
||||
task reserved: :environment do
|
||||
start = Time.zone.now.to_f
|
||||
puts '-----> Importing reserved domains...'
|
||||
|
||||
reserved_domains = []
|
||||
count = 0
|
||||
|
||||
existing_ids = ReservedDomain.pluck(:legacy_id)
|
||||
|
||||
Legacy::Domain.includes(
|
||||
:object_registry,
|
||||
:object
|
||||
).find_each(batch_size: 1000).with_index do |x, index|
|
||||
|
||||
next if existing_ids.include?(x.id) || Registrar.find_by(legacy_id: x.object.try(:clid)).try(:name) != 'eedirect'
|
||||
count += 1
|
||||
|
||||
reserved_domains << ReservedDomain.new({
|
||||
created_at: x.object_registry.try(:crdate),
|
||||
updated_at: x.object.read_attribute(:update).nil? ? x.object_registry.try(:crdate) : x.object.read_attribute(:update),
|
||||
creator_str: x.object_registry.try(:registrar).try(:name),
|
||||
updator_str: x.object.try(:registrar).try(:name) ? x.object.try(:registrar).try(:name) : x.object_registry.try(:registrar).try(:name),
|
||||
names: '"' + x.object_registry.name.try(:strip) + '"=>"' + SecureRandom.hex + '"',
|
||||
legacy_id: x.id
|
||||
})
|
||||
|
||||
if index % 1000 == 0 && index != 0
|
||||
ReservedDomain.import reserved_domains, {validate: false, timestamps: false}
|
||||
reserved_domains = []
|
||||
end
|
||||
end
|
||||
ReservedDomain.import reserved_domains, {validate: false, timestamps: false}
|
||||
puts "-----> Imported #{count} new reserved domains in #{(Time.zone.now.to_f - start).round(2)} seconds"
|
||||
end
|
||||
|
||||
desc 'Import domains'
|
||||
task domains: :environment do
|
||||
start = Time.zone.now.to_f
|
||||
puts '-----> Importing domains...'
|
||||
|
||||
domain_columns = %w(
|
||||
name
|
||||
registrar_id
|
||||
registered_at
|
||||
valid_to
|
||||
transfer_code
|
||||
created_at
|
||||
updated_at
|
||||
name_dirty
|
||||
name_puny
|
||||
period
|
||||
period_unit
|
||||
creator_str
|
||||
updator_str
|
||||
legacy_id
|
||||
legacy_registrar_id
|
||||
legacy_registrant_id
|
||||
statuses
|
||||
)
|
||||
|
||||
domain_contact_columns = %w(
|
||||
type
|
||||
creator_str
|
||||
updator_str
|
||||
legacy_domain_id
|
||||
legacy_contact_id
|
||||
)
|
||||
|
||||
domain_status_columns = %w(
|
||||
description
|
||||
value
|
||||
creator_str
|
||||
updator_str
|
||||
legacy_domain_id
|
||||
)
|
||||
|
||||
nameserver_columns = %w(
|
||||
hostname
|
||||
ipv4
|
||||
ipv6
|
||||
creator_str
|
||||
updator_str
|
||||
legacy_domain_id
|
||||
created_at
|
||||
updated_at
|
||||
)
|
||||
|
||||
dnskey_columns = %w(
|
||||
flags
|
||||
protocol
|
||||
alg
|
||||
public_key
|
||||
creator_str
|
||||
updator_str
|
||||
legacy_domain_id
|
||||
updated_at
|
||||
)
|
||||
|
||||
domains, nameservers, dnskeys, domain_contacts = [], [], [], []
|
||||
existing_domain_ids = Domain.pluck(:legacy_id)
|
||||
user = "rake-#{`whoami`.strip} #{ARGV.join ' '}"
|
||||
count = 0
|
||||
|
||||
Legacy::Domain.includes(
|
||||
:object_registry,
|
||||
:object,
|
||||
:nsset,
|
||||
:object_states,
|
||||
:dnskeys,
|
||||
:domain_contact_maps,
|
||||
nsset: { hosts: :host_ipaddr_maps }
|
||||
).find_each(batch_size: 10000).with_index do |x, index|
|
||||
next if existing_domain_ids.include?(x.id) || Registrar.find_by(legacy_id: x.object.try(:clid)).try(:name) == 'eedirect'
|
||||
count += 1
|
||||
|
||||
begin
|
||||
# domain statuses
|
||||
domain_statuses = []
|
||||
x.object_states.each do |state|
|
||||
next if state.name.blank?
|
||||
domain_statuses << state.name
|
||||
end
|
||||
|
||||
# OK status is default
|
||||
domain_statuses << DomainStatus::OK if domain_statuses.empty?
|
||||
|
||||
domains << [
|
||||
x.object_registry.name.try(:strip),
|
||||
Registrar.find_by(legacy_id: x.object.try(:clid)).try(:id),
|
||||
x.object_registry.try(:crdate),
|
||||
x.object_registry.try(:crdate),
|
||||
x.exdate,
|
||||
x.object.authinfopw.try(:strip),
|
||||
x.object_registry.try(:crdate),
|
||||
x.object.read_attribute(:update).nil? ? x.object_registry.try(:crdate) : x.object.read_attribute(:update),
|
||||
x.object_registry.name.try(:strip),
|
||||
SimpleIDN.to_ascii(x.object_registry.name.try(:strip)),
|
||||
1,
|
||||
'y',
|
||||
x.object_registry.try(:registrar).try(:name),
|
||||
x.object.try(:registrar).try(:name) ? x.object.try(:registrar).try(:name) : x.object_registry.try(:registrar).try(:name),
|
||||
x.id,
|
||||
x.object_registry.try(:crid),
|
||||
x.registrant,
|
||||
domain_statuses
|
||||
]
|
||||
|
||||
# admin contacts
|
||||
x.domain_contact_maps.each do |dc|
|
||||
domain_contacts << [
|
||||
'AdminDomainContact',
|
||||
x.object_registry.try(:registrar).try(:name),
|
||||
x.object.try(:registrar).try(:name) ? x.object.try(:registrar).try(:name) : x.object_registry.try(:registrar).try(:name),
|
||||
x.id,
|
||||
dc.contactid
|
||||
]
|
||||
end
|
||||
|
||||
# tech contacts
|
||||
x.nsset_contact_maps.each do |dc|
|
||||
domain_contacts << [
|
||||
'TechDomainContact',
|
||||
x.object_registry.try(:registrar).try(:name),
|
||||
x.object.try(:registrar).try(:name) ? x.object.try(:registrar).try(:name) : x.object_registry.try(:registrar).try(:name),
|
||||
x.id,
|
||||
dc.contactid
|
||||
]
|
||||
end
|
||||
|
||||
# nameservers
|
||||
nsset = x.nsset
|
||||
nsset.hosts.each do |host|
|
||||
ip_maps = host.host_ipaddr_maps
|
||||
ips = {
|
||||
ipv4: [],
|
||||
ipv6: [],
|
||||
}
|
||||
ip_maps.each do |ip_map|
|
||||
next unless ip_map.ipaddr
|
||||
ips[:ipv4] << ip_map.ipaddr.to_s.strip if ip_map.ipaddr.ipv4?
|
||||
ips[:ipv6] << ip_map.ipaddr.to_s.strip if ip_map.ipaddr.ipv6?
|
||||
end
|
||||
|
||||
nameservers << [
|
||||
host.fqdn.try(:strip),
|
||||
ips[:ipv4],
|
||||
ips[:ipv6],
|
||||
x.object_registry.try(:registrar).try(:name),
|
||||
x.object.try(:registrar).try(:name) ? x.object.try(:registrar).try(:name) : x.object_registry.try(:registrar).try(:name),
|
||||
x.id,
|
||||
nsset.object_registry.try(:crdate),
|
||||
nsset.object_registry.try(:object_history).read_attribute(:update).nil? ? nsset.object_registry.try(:crdate) : nsset.object_registry.try(:object_history).read_attribute(:update)
|
||||
]
|
||||
end if x.nsset && x.nsset.hosts
|
||||
|
||||
x.dnskeys.each do |key|
|
||||
dnskeys << [
|
||||
key.flags,
|
||||
key.protocol,
|
||||
key.alg,
|
||||
key.key,
|
||||
x.object_registry.try(:registrar).try(:name),
|
||||
x.object.try(:registrar).try(:name) ? x.object.try(:registrar).try(:name) : x.object_registry.try(:registrar).try(:name),
|
||||
x.id,
|
||||
key.object_registry.try(:object_history).read_attribute(:update).nil? ? key.try(:crdate)||Time.zone.now : key.object_registry.try(:object_history).read_attribute(:update)
|
||||
]
|
||||
end
|
||||
|
||||
if index % 10000 == 0 && index != 0
|
||||
Domain.import domain_columns, domains, {validate: false, timestamps: false}
|
||||
Nameserver.import nameserver_columns, nameservers, {validate: false, timestamps: false}
|
||||
Dnskey.import dnskey_columns, dnskeys, {validate: false, timestamps: false}
|
||||
DomainContact.import domain_contact_columns, domain_contacts, validate: false # created_at is taken from contact at the bottom
|
||||
domains, nameservers, dnskeys, domain_contacts = [], [], [], []
|
||||
end
|
||||
rescue => e
|
||||
puts "ERROR on index #{index}"
|
||||
puts e
|
||||
end
|
||||
end
|
||||
|
||||
Domain.import domain_columns, domains, {validate: false, timestamps: false}
|
||||
Nameserver.import nameserver_columns, nameservers, {validate: false, timestamps: false}
|
||||
Dnskey.import dnskey_columns, dnskeys, {validate: false, timestamps: false}
|
||||
DomainContact.import domain_contact_columns, domain_contacts, validate: false
|
||||
|
||||
puts '-----> Updating relations...'
|
||||
|
||||
# registrant
|
||||
ActiveRecord::Base.connection.execute(
|
||||
"UPDATE domains "\
|
||||
"SET registrant_id = contacts.id "\
|
||||
"FROM contacts "\
|
||||
"WHERE contacts.legacy_id = legacy_registrant_id "\
|
||||
"AND legacy_registrant_id IS NOT NULL "\
|
||||
"AND registrant_id IS NULL"
|
||||
)
|
||||
|
||||
# registrar
|
||||
ActiveRecord::Base.connection.execute(
|
||||
"UPDATE domains "\
|
||||
"SET registrar_id = registrars.id "\
|
||||
"FROM registrars "\
|
||||
"WHERE registrars.legacy_id = legacy_registrar_id "\
|
||||
"AND legacy_registrar_id IS NOT NULL "\
|
||||
"AND registrar_id IS NULL"
|
||||
)
|
||||
|
||||
# contacts
|
||||
ActiveRecord::Base.connection.execute(
|
||||
"UPDATE domain_contacts "\
|
||||
"SET contact_id = contacts.id, "\
|
||||
"updated_at = contacts.updated_at, "\
|
||||
"created_at = contacts.created_at "\
|
||||
"FROM contacts "\
|
||||
"WHERE contacts.legacy_id = legacy_contact_id "\
|
||||
"AND legacy_contact_id IS NOT NULL "\
|
||||
"AND contact_id IS NULL"
|
||||
)
|
||||
|
||||
ActiveRecord::Base.connection.execute(
|
||||
"UPDATE domain_contacts "\
|
||||
"SET domain_id = domains.id "\
|
||||
"FROM domains "\
|
||||
"WHERE domains.legacy_id = legacy_domain_id "\
|
||||
"AND legacy_domain_id IS NOT NULL "\
|
||||
"AND domain_id IS NULL"
|
||||
)
|
||||
|
||||
# nameservers
|
||||
ActiveRecord::Base.connection.execute(
|
||||
"UPDATE nameservers "\
|
||||
"SET domain_id = domains.id "\
|
||||
"FROM domains "\
|
||||
"WHERE domains.legacy_id = legacy_domain_id "\
|
||||
"AND legacy_domain_id IS NOT NULL "\
|
||||
"AND domain_id IS NULL"
|
||||
)
|
||||
|
||||
# dnskeys
|
||||
ActiveRecord::Base.connection.execute(
|
||||
"UPDATE dnskeys "\
|
||||
"SET domain_id = domains.id "\
|
||||
"FROM domains "\
|
||||
"WHERE domains.legacy_id = legacy_domain_id "\
|
||||
"AND legacy_domain_id IS NOT NULL "\
|
||||
"AND domain_id IS NULL"
|
||||
)
|
||||
|
||||
puts '-----> Generating dnskey digests...'
|
||||
|
||||
Dnskey.all.each do |ds|
|
||||
ds.generate_digest
|
||||
ds.generate_ds_key_tag
|
||||
ds.save(validate: false)
|
||||
end
|
||||
|
||||
puts "-----> Imported #{count} new domains in #{(Time.zone.now.to_f - start).round(2)} seconds"
|
||||
end
|
||||
|
||||
desc 'Import zones'
|
||||
task zones: :environment do
|
||||
start = Time.zone.now.to_f
|
||||
puts '-----> Importing zones...'
|
||||
|
||||
ns_records, a_records, a4_records = parse_zone_ns_data('ee', 1)
|
||||
|
||||
DNS::Zone.create!({
|
||||
origin: 'ee',
|
||||
ttl: 43200,
|
||||
refresh: 3600,
|
||||
retry: 900,
|
||||
expire: 1209600,
|
||||
minimum_ttl: 3600,
|
||||
email: 'hostmaster.eestiinternet.ee',
|
||||
master_nameserver: 'ns.tld.ee',
|
||||
ns_records: ns_records,
|
||||
a_records: a_records,
|
||||
a4_records: a4_records
|
||||
})
|
||||
|
||||
# edu.ee
|
||||
ns_records, a_records, a4_records = parse_zone_ns_data('edu.ee', 6)
|
||||
|
||||
DNS::Zone.create!({
|
||||
origin: 'edu.ee',
|
||||
ttl: 43200,
|
||||
refresh: 3600,
|
||||
retry: 900,
|
||||
expire: 1209600,
|
||||
minimum_ttl: 3600,
|
||||
email: 'hostmaster.eestiinternet.ee',
|
||||
master_nameserver: 'ns.tld.ee',
|
||||
ns_records: ns_records,
|
||||
a_records: a_records,
|
||||
a4_records: a4_records
|
||||
})
|
||||
|
||||
# aip.ee
|
||||
ns_records, a_records, a4_records = parse_zone_ns_data('aip.ee', 9)
|
||||
|
||||
DNS::Zone.create!({
|
||||
origin: 'aip.ee',
|
||||
ttl: 43200,
|
||||
refresh: 3600,
|
||||
retry: 900,
|
||||
expire: 1209600,
|
||||
minimum_ttl: 3600,
|
||||
email: 'hostmaster.eestiinternet.ee',
|
||||
master_nameserver: 'ns.tld.ee',
|
||||
ns_records: ns_records,
|
||||
a_records: a_records,
|
||||
a4_records: a4_records
|
||||
})
|
||||
|
||||
# org.ee
|
||||
ns_records, a_records, a4_records = parse_zone_ns_data('org.ee', 10)
|
||||
|
||||
DNS::Zone.create!({
|
||||
origin: 'org.ee',
|
||||
ttl: 43200,
|
||||
refresh: 3600,
|
||||
retry: 900,
|
||||
expire: 1209600,
|
||||
minimum_ttl: 3600,
|
||||
email: 'hostmaster.eestiinternet.ee',
|
||||
master_nameserver: 'ns.tld.ee',
|
||||
ns_records: ns_records,
|
||||
a_records: a_records,
|
||||
a4_records: a4_records
|
||||
})
|
||||
|
||||
# pri.ee
|
||||
ns_records, a_records, a4_records = parse_zone_ns_data('pri.ee', 2)
|
||||
|
||||
DNS::Zone.create!({
|
||||
origin: 'pri.ee',
|
||||
ttl: 43200,
|
||||
refresh: 3600,
|
||||
retry: 900,
|
||||
expire: 1209600,
|
||||
minimum_ttl: 3600,
|
||||
email: 'hostmaster.eestiinternet.ee',
|
||||
master_nameserver: 'ns.tld.ee',
|
||||
ns_records: ns_records,
|
||||
a_records: a_records,
|
||||
a4_records: a4_records
|
||||
})
|
||||
|
||||
# med.ee
|
||||
ns_records, a_records, a4_records = parse_zone_ns_data('med.ee', 3)
|
||||
|
||||
DNS::Zone.create!({
|
||||
origin: 'med.ee',
|
||||
ttl: 43200,
|
||||
refresh: 3600,
|
||||
retry: 900,
|
||||
expire: 1209600,
|
||||
minimum_ttl: 3600,
|
||||
email: 'hostmaster.eestiinternet.ee',
|
||||
master_nameserver: 'ns.tld.ee',
|
||||
ns_records: ns_records,
|
||||
a_records: a_records,
|
||||
a4_records: a4_records
|
||||
})
|
||||
|
||||
# fie.ee
|
||||
ns_records, a_records, a4_records = parse_zone_ns_data('fie.ee', 4)
|
||||
|
||||
DNS::Zone.create!({
|
||||
origin: 'fie.ee',
|
||||
ttl: 43200,
|
||||
refresh: 3600,
|
||||
retry: 900,
|
||||
expire: 1209600,
|
||||
minimum_ttl: 3600,
|
||||
email: 'hostmaster.eestiinternet.ee',
|
||||
master_nameserver: 'ns.tld.ee',
|
||||
ns_records: ns_records,
|
||||
a_records: a_records,
|
||||
a4_records: a4_records
|
||||
})
|
||||
|
||||
# com.ee
|
||||
ns_records, a_records, a4_records = parse_zone_ns_data('com.ee', 5)
|
||||
|
||||
DNS::Zone.create!({
|
||||
origin: 'com.ee',
|
||||
ttl: 43200,
|
||||
refresh: 3600,
|
||||
retry: 900,
|
||||
expire: 1209600,
|
||||
minimum_ttl: 3600,
|
||||
email: 'hostmaster.eestiinternet.ee',
|
||||
master_nameserver: 'ns.tld.ee',
|
||||
ns_records: ns_records,
|
||||
a_records: a_records,
|
||||
a4_records: a4_records
|
||||
})
|
||||
|
||||
# gov.ee
|
||||
ns_records, a_records, a4_records = parse_zone_ns_data('gov.ee', 7)
|
||||
|
||||
DNS::Zone.create!({
|
||||
origin: 'gov.ee',
|
||||
ttl: 43200,
|
||||
refresh: 3600,
|
||||
retry: 900,
|
||||
expire: 1209600,
|
||||
minimum_ttl: 3600,
|
||||
email: 'hostmaster.eestiinternet.ee',
|
||||
master_nameserver: 'ns.tld.ee',
|
||||
ns_records: ns_records,
|
||||
a_records: a_records,
|
||||
a4_records: a4_records
|
||||
})
|
||||
|
||||
# riik.ee
|
||||
ns_records, a_records, a4_records = parse_zone_ns_data('riik.ee', 8)
|
||||
|
||||
DNS::Zone.create!({
|
||||
origin: 'riik.ee',
|
||||
ttl: 43200,
|
||||
refresh: 3600,
|
||||
retry: 900,
|
||||
expire: 1209600,
|
||||
minimum_ttl: 3600,
|
||||
email: 'hostmaster.eestiinternet.ee',
|
||||
master_nameserver: 'ns.tld.ee',
|
||||
ns_records: ns_records,
|
||||
a_records: a_records,
|
||||
a4_records: a4_records
|
||||
})
|
||||
|
||||
puts "-----> Imported zones in #{(Time.zone.now.to_f - start).round(2)} seconds"
|
||||
end
|
||||
end
|
||||
|
||||
def parse_zone_ns_data(domain, zone)
|
||||
ns_records = ''
|
||||
a_records = ''
|
||||
a4_records = ''
|
||||
Legacy::ZoneNs.where(zone: zone).each do |x|
|
||||
ipv4 = x.addrs.select { |addr| addr.ipv4? }.first
|
||||
ipv6 = x.addrs.select { |addr| addr.ipv6? }.first
|
||||
|
||||
ns_records += "#{domain}. IN NS #{x.fqdn}.\n"
|
||||
a_records += "#{x.fqdn}. IN A #{ipv4}\n" if ipv4.present?
|
||||
a4_records += "#{x.fqdn}. IN AAAA #{ipv6}\n" if ipv6.present?
|
||||
end
|
||||
[ns_records.strip, a_records.strip, a4_records.strip]
|
||||
end
|
46
lib/tasks/invoices/process_payments.rake
Normal file
46
lib/tasks/invoices/process_payments.rake
Normal file
|
@ -0,0 +1,46 @@
|
|||
namespace :invoices do
|
||||
task process_payments: :environment do
|
||||
registry_bank_account_iban = Setting.registry_iban
|
||||
|
||||
keystore = OpenSSL::PKCS12.new(File.read(ENV['lhv_p12_keystore']), ENV['lhv_keystore_password'])
|
||||
key = keystore.key
|
||||
cert = keystore.certificate
|
||||
|
||||
api = Lhv::ConnectApi.new
|
||||
api.cert = cert
|
||||
api.key = key
|
||||
api.ca_file = ENV['lhv_ca_file']
|
||||
api.dev_mode = ENV['lhv_dev_mode'] == 'true'
|
||||
|
||||
incoming_transactions = []
|
||||
|
||||
api.credit_debit_notification_messages.each do |message|
|
||||
next unless message.bank_account_iban == registry_bank_account_iban
|
||||
|
||||
message.credit_transactions.each do |credit_transaction|
|
||||
incoming_transactions << credit_transaction
|
||||
end
|
||||
end
|
||||
|
||||
if incoming_transactions.any?
|
||||
bank_statement = BankStatement.new(bank_code: Setting.registry_bank_code,
|
||||
iban: Setting.registry_iban)
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
bank_statement.save!
|
||||
|
||||
incoming_transactions.each do |incoming_transaction|
|
||||
transaction_attributes = { sum: incoming_transaction.amount,
|
||||
currency: incoming_transaction.currency,
|
||||
paid_at: incoming_transaction.date,
|
||||
reference_no: incoming_transaction.payment_reference_number,
|
||||
description: incoming_transaction.payment_description }
|
||||
transaction = bank_statement.bank_transactions.create!(transaction_attributes)
|
||||
transaction.autobind_invoice
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
puts "Transactions processed: #{incoming_transactions.size}"
|
||||
end
|
||||
end
|
|
@ -1,625 +0,0 @@
|
|||
desc 'Schema load for all databases: registry, api_log and whois'
|
||||
task statuses: [:environment] do
|
||||
statuses = {
|
||||
'ok': [
|
||||
],
|
||||
'inactive': [
|
||||
'clientDeleteProhibited',
|
||||
'serverDeleteProhibited',
|
||||
'clientHold',
|
||||
'serverHold',
|
||||
'clientRenewProhibited',
|
||||
'serverRenewProhibited',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited',
|
||||
'serverRegistrantChangeProhibited',
|
||||
'serverAdminChangeProhibited',
|
||||
'serverTechChangeProhibited',
|
||||
'serverForceDelete',
|
||||
'deleteCandidate',
|
||||
'expired'
|
||||
],
|
||||
'clientDeleteProhibited': [
|
||||
'serverDeleteProhibited',
|
||||
'clientHold',
|
||||
'serverHold',
|
||||
'clientRenewProhibited',
|
||||
'serverRenewProhibited',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited',
|
||||
'inactive',
|
||||
'serverManualInzone',
|
||||
'serverRegistrantChangeProhibited',
|
||||
'serverAdminChangeProhibited',
|
||||
'serverTechChangeProhibited',
|
||||
'serverForceDelete',
|
||||
'deleteCandidate',
|
||||
'expired'
|
||||
],
|
||||
'serverDeleteProhibited': [
|
||||
'clientDeleteProhibited',
|
||||
'clientHold',
|
||||
'serverHold',
|
||||
'clientRenewProhibited',
|
||||
'serverRenewProhibited',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited',
|
||||
'inactive',
|
||||
'serverManualInzone',
|
||||
'serverRegistrantChangeProhibited',
|
||||
'serverAdminChangeProhibited',
|
||||
'serverTechChangeProhibited',
|
||||
'serverForceDelete',
|
||||
'deleteCandidate',
|
||||
'expired'
|
||||
],
|
||||
'clientHold': [
|
||||
'clientDeleteProhibited',
|
||||
'serverDeleteProhibited',
|
||||
'serverHold',
|
||||
'clientRenewProhibited',
|
||||
'serverRenewProhibited',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited',
|
||||
'inactive',
|
||||
'serverRegistrantChangeProhibited',
|
||||
'serverAdminChangeProhibited',
|
||||
'serverTechChangeProhibited',
|
||||
'serverForceDelete',
|
||||
'deleteCandidate',
|
||||
'expired'
|
||||
],
|
||||
'serverHold': [
|
||||
'clientDeleteProhibited',
|
||||
'serverDeleteProhibited',
|
||||
'clientHold',
|
||||
'clientRenewProhibited',
|
||||
'serverRenewProhibited',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited',
|
||||
'inactive',
|
||||
'serverRegistrantChangeProhibited',
|
||||
'serverAdminChangeProhibited',
|
||||
'serverTechChangeProhibited',
|
||||
'serverForceDelete',
|
||||
'deleteCandidate',
|
||||
'expired'
|
||||
],
|
||||
'clientRenewProhibited': [
|
||||
'clientDeleteProhibited',
|
||||
'serverDeleteProhibited',
|
||||
'clientHold',
|
||||
'serverHold',
|
||||
'serverRenewProhibited',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited',
|
||||
'inactive',
|
||||
'pendingCreate',
|
||||
'pendingDelete',
|
||||
'pendingDeleteConfirmation',
|
||||
'pendingTransfer',
|
||||
'pendingUpdate',
|
||||
'serverManualInzone',
|
||||
'serverRegistrantChangeProhibited',
|
||||
'serverAdminChangeProhibited',
|
||||
'serverTechChangeProhibited',
|
||||
'serverForceDelete',
|
||||
'deleteCandidate',
|
||||
'expired'
|
||||
],
|
||||
'serverRenewProhibited': [
|
||||
'clientDeleteProhibited',
|
||||
'serverDeleteProhibited',
|
||||
'clientHold',
|
||||
'serverHold',
|
||||
'clientRenewProhibited',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited',
|
||||
'inactive',
|
||||
'pendingCreate',
|
||||
'pendingDelete',
|
||||
'pendingDeleteConfirmation',
|
||||
'pendingTransfer',
|
||||
'pendingUpdate',
|
||||
'serverManualInzone',
|
||||
'serverRegistrantChangeProhibited',
|
||||
'serverAdminChangeProhibited',
|
||||
'serverTechChangeProhibited',
|
||||
'serverForceDelete',
|
||||
'deleteCandidate',
|
||||
'expired'
|
||||
],
|
||||
'clientTransferProhibited': [
|
||||
'clientDeleteProhibited',
|
||||
'serverDeleteProhibited',
|
||||
'clientHold',
|
||||
'serverHold',
|
||||
'clientRenewProhibited',
|
||||
'serverRenewProhibited',
|
||||
'serverTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited',
|
||||
'inactive',
|
||||
'pendingCreate',
|
||||
'pendingDelete',
|
||||
'pendingDeleteConfirmation',
|
||||
'pendingRenew',
|
||||
'pendingUpdate',
|
||||
'serverManualInzone',
|
||||
'serverRegistrantChangeProhibited',
|
||||
'serverAdminChangeProhibited',
|
||||
'serverTechChangeProhibited',
|
||||
'serverForceDelete',
|
||||
'deleteCandidate',
|
||||
'expired'
|
||||
],
|
||||
'serverTransferProhibited': [
|
||||
'clientDeleteProhibited',
|
||||
'serverDeleteProhibited',
|
||||
'clientHold',
|
||||
'serverHold',
|
||||
'clientRenewProhibited',
|
||||
'serverRenewProhibited',
|
||||
'clientTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited',
|
||||
'inactive',
|
||||
'pendingCreate',
|
||||
'pendingDelete',
|
||||
'pendingDeleteConfirmation',
|
||||
'pendingRenew',
|
||||
'pendingUpdate',
|
||||
'serverManualInzone',
|
||||
'serverRegistrantChangeProhibited',
|
||||
'serverAdminChangeProhibited',
|
||||
'serverTechChangeProhibited',
|
||||
'serverForceDelete',
|
||||
'deleteCandidate',
|
||||
'expired'
|
||||
],
|
||||
'clientUpdateProhibited': [
|
||||
'clientDeleteProhibited',
|
||||
'serverDeleteProhibited',
|
||||
'clientHold',
|
||||
'serverHold',
|
||||
'clientRenewProhibited',
|
||||
'serverRenewProhibited',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'serverUpdateProhibited',
|
||||
'inactive',
|
||||
'pendingCreate',
|
||||
'pendingDelete',
|
||||
'pendingDeleteConfirmation',
|
||||
'pendingRenew',
|
||||
'pendingTransfer',
|
||||
'serverManualInzone',
|
||||
'serverRegistrantChangeProhibited',
|
||||
'serverAdminChangeProhibited',
|
||||
'serverTechChangeProhibited',
|
||||
'serverForceDelete',
|
||||
'deleteCandidate',
|
||||
'expired'
|
||||
],
|
||||
'serverUpdateProhibited': [
|
||||
'clientDeleteProhibited',
|
||||
'serverDeleteProhibited',
|
||||
'clientHold',
|
||||
'serverHold',
|
||||
'clientRenewProhibited',
|
||||
'serverRenewProhibited',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'inactive',
|
||||
'pendingCreate',
|
||||
'pendingDelete',
|
||||
'pendingDeleteConfirmation',
|
||||
'pendingRenew',
|
||||
'pendingTransfer',
|
||||
'serverManualInzone',
|
||||
'serverRegistrantChangeProhibited',
|
||||
'serverAdminChangeProhibited',
|
||||
'serverTechChangeProhibited',
|
||||
'serverForceDelete',
|
||||
'deleteCandidate',
|
||||
'expired'
|
||||
],
|
||||
'pendingCreate': [
|
||||
'clientDeleteProhibited',
|
||||
'serverDeleteProhibited',
|
||||
'clientHold',
|
||||
'serverHold',
|
||||
'clientRenewProhibited',
|
||||
'serverRenewProhibited',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited',
|
||||
'inactive',
|
||||
'serverManualInzone',
|
||||
'serverRegistrantChangeProhibited',
|
||||
'serverAdminChangeProhibited',
|
||||
'serverTechChangeProhibited',
|
||||
'serverForceDelete',
|
||||
'deleteCandidate',
|
||||
'expired'
|
||||
],
|
||||
'pendingDelete': [
|
||||
'clientHold',
|
||||
'serverHold',
|
||||
'clientRenewProhibited',
|
||||
'serverRenewProhibited',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited',
|
||||
'inactive',
|
||||
'pendingDeleteConfirmation',
|
||||
'serverManualInzone',
|
||||
'serverRegistrantChangeProhibited',
|
||||
'serverAdminChangeProhibited',
|
||||
'serverTechChangeProhibited',
|
||||
'serverForceDelete',
|
||||
'deleteCandidate',
|
||||
'expired'
|
||||
],
|
||||
'pendingRenew': [
|
||||
'clientDeleteProhibited',
|
||||
'serverDeleteProhibited',
|
||||
'clientHold',
|
||||
'serverHold',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited',
|
||||
'inactive',
|
||||
'serverManualInzone',
|
||||
'serverRegistrantChangeProhibited',
|
||||
'serverAdminChangeProhibited',
|
||||
'serverTechChangeProhibited',
|
||||
'serverForceDelete',
|
||||
'deleteCandidate',
|
||||
'expired'
|
||||
|
||||
],
|
||||
'pendingTransfer': [
|
||||
'clientDeleteProhibited',
|
||||
'serverDeleteProhibited',
|
||||
'clientHold',
|
||||
'serverHold',
|
||||
'clientRenewProhibited',
|
||||
'serverRenewProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited',
|
||||
'inactive',
|
||||
'serverManualInzone',
|
||||
'serverRegistrantChangeProhibited',
|
||||
'serverAdminChangeProhibited',
|
||||
'serverTechChangeProhibited',
|
||||
'serverForceDelete',
|
||||
'deleteCandidate',
|
||||
'expired'
|
||||
],
|
||||
'pendingUpdate': [
|
||||
'clientDeleteProhibited',
|
||||
'serverDeleteProhibited',
|
||||
'clientHold',
|
||||
'serverHold',
|
||||
'clientRenewProhibited',
|
||||
'serverRenewProhibited',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'inactive',
|
||||
'serverManualInzone',
|
||||
'serverRegistrantChangeProhibited',
|
||||
'serverAdminChangeProhibited',
|
||||
'serverTechChangeProhibited',
|
||||
'serverForceDelete',
|
||||
'deleteCandidate',
|
||||
'expired'
|
||||
],
|
||||
'serverManualInzone': [
|
||||
'clientDeleteProhibited',
|
||||
'serverDeleteProhibited',
|
||||
'clientHold',
|
||||
'serverHold',
|
||||
'clientRenewProhibited',
|
||||
'serverRenewProhibited',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited',
|
||||
'pendingCreate',
|
||||
'pendingDelete',
|
||||
'pendingDeleteConfirmation',
|
||||
'pendingRenew',
|
||||
'pendingTransfer',
|
||||
'pendingUpdate',
|
||||
'serverRegistrantChangeProhibited',
|
||||
'serverAdminChangeProhibited',
|
||||
'serverTechChangeProhibited',
|
||||
'serverForceDelete',
|
||||
'deleteCandidate',
|
||||
'expired'
|
||||
],
|
||||
'serverRegistrantChangeProhibited': [
|
||||
'clientDeleteProhibited',
|
||||
'serverDeleteProhibited',
|
||||
'clientHold',
|
||||
'serverHold',
|
||||
'clientRenewProhibited',
|
||||
'serverRenewProhibited',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited',
|
||||
'inactive',
|
||||
'pendingCreate',
|
||||
'pendingDelete',
|
||||
'pendingDeleteConfirmation',
|
||||
'pendingRenew',
|
||||
'pendingTransfer',
|
||||
'pendingUpdate',
|
||||
'serverManualInzone',
|
||||
'serverAdminChangeProhibited',
|
||||
'serverTechChangeProhibited',
|
||||
'serverForceDelete',
|
||||
'deleteCandidate',
|
||||
'expired'
|
||||
],
|
||||
'serverAdminChangeProhibited': [
|
||||
'clientDeleteProhibited',
|
||||
'serverDeleteProhibited',
|
||||
'clientHold',
|
||||
'serverHold',
|
||||
'clientRenewProhibited',
|
||||
'serverRenewProhibited',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited',
|
||||
'inactive',
|
||||
'pendingCreate',
|
||||
'pendingDelete',
|
||||
'pendingDeleteConfirmation',
|
||||
'pendingRenew',
|
||||
'pendingTransfer',
|
||||
'pendingUpdate',
|
||||
'serverManualInzone',
|
||||
'serverRegistrantChangeProhibited',
|
||||
'serverTechChangeProhibited',
|
||||
'serverForceDelete',
|
||||
'deleteCandidate',
|
||||
'expired'
|
||||
],
|
||||
'serverTechChangeProhibited': [
|
||||
'clientDeleteProhibited',
|
||||
'serverDeleteProhibited',
|
||||
'clientHold',
|
||||
'serverHold',
|
||||
'clientRenewProhibited',
|
||||
'serverRenewProhibited',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited',
|
||||
'inactive',
|
||||
'pendingCreate',
|
||||
'pendingDelete',
|
||||
'pendingDeleteConfirmation',
|
||||
'pendingRenew',
|
||||
'pendingTransfer',
|
||||
'pendingUpdate',
|
||||
'serverManualInzone',
|
||||
'serverRegistrantChangeProhibited',
|
||||
'serverAdminChangeProhibited',
|
||||
'serverForceDelete',
|
||||
'deleteCandidate',
|
||||
'expired'
|
||||
],
|
||||
'serverForceDelete': [
|
||||
'clientHold',
|
||||
'serverHold',
|
||||
'inactive',
|
||||
'serverManualInzone',
|
||||
'serverRegistrantChangeProhibited',
|
||||
'serverAdminChangeProhibited',
|
||||
'serverTechChangeProhibited',
|
||||
'deleteCandidate',
|
||||
'expired'
|
||||
],
|
||||
'deleteCandidate': [
|
||||
'clientDeleteProhibited',
|
||||
'serverDeleteProhibited',
|
||||
'clientHold',
|
||||
'serverHold',
|
||||
'clientRenewProhibited',
|
||||
'serverRenewProhibited',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited',
|
||||
'inactive',
|
||||
'pendingCreate',
|
||||
'pendingDelete',
|
||||
'pendingDeleteConfirmation',
|
||||
'pendingRenew',
|
||||
'pendingTransfer',
|
||||
'pendingUpdate',
|
||||
'serverManualInzone',
|
||||
'serverRegistrantChangeProhibited',
|
||||
'serverAdminChangeProhibited',
|
||||
'serverTechChangeProhibited',
|
||||
'serverForceDelete',
|
||||
'deleteCandidate',
|
||||
'expired'
|
||||
],
|
||||
'expired': [
|
||||
'clientDeleteProhibited',
|
||||
'serverDeleteProhibited',
|
||||
'clientHold',
|
||||
'serverHold',
|
||||
'clientRenewProhibited',
|
||||
'serverRenewProhibited',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited',
|
||||
'inactive',
|
||||
'pendingCreate',
|
||||
'pendingDelete',
|
||||
'pendingDeleteConfirmation',
|
||||
'pendingRenew',
|
||||
'pendingTransfer',
|
||||
'pendingUpdate',
|
||||
'serverManualInzone',
|
||||
'serverRegistrantChangeProhibited',
|
||||
'serverAdminChangeProhibited',
|
||||
'serverTechChangeProhibited',
|
||||
'serverForceDelete',
|
||||
'deleteCandidate'
|
||||
]
|
||||
}
|
||||
|
||||
puts "\nDomain status can be with other statuses map\n"
|
||||
puts "---------------------------------------------"
|
||||
statuses.each do |s, _v|
|
||||
puts "\n#{s} =>"
|
||||
statuses[s].map { |u| puts " #{u}" }
|
||||
puts
|
||||
end
|
||||
|
||||
contact_statuses = {
|
||||
'ok': [
|
||||
'linked'
|
||||
],
|
||||
'linked': [
|
||||
'ok'
|
||||
],
|
||||
'clientDeleteProhibited': [
|
||||
'linked',
|
||||
'serverDeleteProhibited',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited',
|
||||
'pendingCreate',
|
||||
'pendingTransfer',
|
||||
'pendingUpdate'
|
||||
],
|
||||
'serverDeleteProhibited': [
|
||||
'linked',
|
||||
'clientDeleteProhibited',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited',
|
||||
'pendingCreate',
|
||||
'pendingTransfer',
|
||||
'pendingUpdate'
|
||||
],
|
||||
'clientTransferProhibited': [
|
||||
'linked',
|
||||
'serverDeleteProhibited',
|
||||
'clientDeleteProhibited',
|
||||
'serverTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited',
|
||||
'pendingCreate',
|
||||
'pendingDelete',
|
||||
'pendingUpdate'
|
||||
],
|
||||
'serverTransferProhibited': [
|
||||
'linked',
|
||||
'serverDeleteProhibited',
|
||||
'clientDeleteProhibited',
|
||||
'clientTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited',
|
||||
'pendingCreate',
|
||||
'pendingDelete',
|
||||
'pendingUpdate'
|
||||
],
|
||||
'clientUpdateProhibited': [
|
||||
'linked',
|
||||
'serverDeleteProhibited',
|
||||
'clientDeleteProhibited',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'serverUpdateProhibited',
|
||||
'pendingCreate',
|
||||
'pendingDelete',
|
||||
'pendingTransfer'
|
||||
],
|
||||
'serverUpdateProhibited': [
|
||||
'linked',
|
||||
'serverDeleteProhibited',
|
||||
'clientDeleteProhibited',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'pendingCreate',
|
||||
'pendingDelete',
|
||||
'pendingTransfer'
|
||||
],
|
||||
'pendingCreate': [
|
||||
'linked',
|
||||
'clientDeleteProhibited',
|
||||
'serverDeleteProhibited',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited'
|
||||
],
|
||||
'pendingDelete': [
|
||||
'linked',
|
||||
'clientDeleteProhibited',
|
||||
'serverDeleteProhibited',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited'
|
||||
],
|
||||
'pendingTransfer': [
|
||||
'linked',
|
||||
'clientDeleteProhibited',
|
||||
'serverDeleteProhibited',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited'
|
||||
],
|
||||
'pendingUpdate': [
|
||||
'linked',
|
||||
'clientDeleteProhibited',
|
||||
'serverDeleteProhibited',
|
||||
'clientTransferProhibited',
|
||||
'serverTransferProhibited',
|
||||
'clientUpdateProhibited',
|
||||
'serverUpdateProhibited'
|
||||
]
|
||||
}
|
||||
|
||||
puts "\n\nContact status can be with other statuses map\n"
|
||||
puts "---------------------------------------------"
|
||||
contact_statuses.each do |s, _v|
|
||||
puts "\n#{s} =>"
|
||||
contact_statuses[s].map { |u| puts " #{u}" }
|
||||
puts
|
||||
end
|
||||
end
|
23
lib/tasks/verify_email.rake
Normal file
23
lib/tasks/verify_email.rake
Normal file
|
@ -0,0 +1,23 @@
|
|||
namespace :verify_email do
|
||||
desc 'Stars verifying email jobs for all the domain'
|
||||
task all_domains: :environment do
|
||||
verifications_by_domain = EmailAddressVerification.not_verified_recently.group_by(&:domain)
|
||||
verifications_by_domain.each do |_domain, verifications|
|
||||
ver = verifications.sample # Verify random email to not to clog the SMTP servers
|
||||
VerifyEmailsJob.enqueue(ver.id)
|
||||
next
|
||||
end
|
||||
end
|
||||
|
||||
# Need to be run like 'bundle exec rake verify_email:domain['gmail.com']'
|
||||
# In zsh syntax will be 'bundle exec rake verify_email:domain\['gmail.com'\]'
|
||||
# Default 'bundle exec rake verify_email:domain' wil use 'internet.ee' domain
|
||||
desc 'Stars verifying email jobs for domain stated in argument'
|
||||
task :domain, [:domain_name] => [:environment] do |_task, args|
|
||||
args.with_defaults(domain_name: 'internet.ee')
|
||||
|
||||
verifications_by_domain = EmailAddressVerification.not_verified_recently
|
||||
.by_domain(args[:domain_name])
|
||||
verifications_by_domain.map { |ver| VerifyEmailsJob.enqueue(ver.id) }
|
||||
end
|
||||
end
|
|
@ -35,6 +35,11 @@ namespace :whois do
|
|||
ReservedDomain.find_in_batches.each do |group|
|
||||
UpdateWhoisRecordJob.enqueue group.map(&:name), 'reserved'
|
||||
end
|
||||
|
||||
print "\n-----> Update disputed domains whois_records"
|
||||
Dispute.active.find_in_batches.each do |group|
|
||||
UpdateWhoisRecordJob.enqueue group.map(&:domain_name), 'disputed'
|
||||
end
|
||||
end
|
||||
puts "\n-----> all done in #{(Time.zone.now.to_f - start).round(2)} seconds"
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue