mirror of
https://github.com/internetee/registry.git
synced 2025-05-19 10:49:39 +02:00
parent
39d7c6ad1d
commit
ad0220088a
30 changed files with 697 additions and 59 deletions
11
app/jobs/domain_expiration_email_job.rb
Normal file
11
app/jobs/domain_expiration_email_job.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
class DomainExpirationEmailJob < ActiveJob::Base
|
||||
queue_as :default
|
||||
|
||||
def perform(domain_id:)
|
||||
domain = Domain.find(domain_id)
|
||||
|
||||
return if domain.registered?
|
||||
|
||||
DomainMailer.expiration(domain).deliver!
|
||||
end
|
||||
end
|
|
@ -117,17 +117,6 @@ class DomainMailer < ApplicationMailer
|
|||
name: @domain.name)} [#{@domain.name}]")
|
||||
end
|
||||
|
||||
def expiration_reminder(domain_id)
|
||||
@domain = Domain.find_by(id: domain_id)
|
||||
return if @domain.nil? || !@domain.statuses.include?(DomainStatus::EXPIRED) || whitelist_blocked?(@domain.registrant.email)
|
||||
return if whitelist_blocked?(@domain.registrant.email)
|
||||
|
||||
mail(to: format(@domain.registrant.email),
|
||||
subject: "#{I18n.t(:expiration_remind_subject,
|
||||
name: @domain.name)} [#{@domain.name}]")
|
||||
end
|
||||
|
||||
|
||||
def force_delete(domain_id, should_deliver)
|
||||
@domain = Domain.find_by(id: domain_id)
|
||||
return if delivery_off?(@domain, should_deliver)
|
||||
|
@ -140,6 +129,16 @@ class DomainMailer < ApplicationMailer
|
|||
)
|
||||
end
|
||||
|
||||
def expiration(domain:)
|
||||
@domain = DomainPresenter.new(domain: domain, view: view_context)
|
||||
@registrar = RegistrarPresenter.new(registrar: domain.registrar, view: view_context)
|
||||
|
||||
recipients = domain.admin_contact_emails << domain.registrant_email
|
||||
|
||||
subject = default_i18n_subject(domain_name: domain.name)
|
||||
mail(to: recipients, subject: subject)
|
||||
end
|
||||
|
||||
private
|
||||
# app/models/DomainMailModel provides the data for mail that can be composed_from
|
||||
# which ensures that values of objects are captured when they are valid, not later when this method is executed
|
||||
|
|
31
app/models/concerns/domain/expirable.rb
Normal file
31
app/models/concerns/domain/expirable.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
module Concerns::Domain::Expirable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
alias_attribute :expire_time, :valid_to
|
||||
end
|
||||
|
||||
class_methods do
|
||||
def expired
|
||||
where("#{attribute_alias(:expire_time)} <= ?", Time.zone.now)
|
||||
end
|
||||
end
|
||||
|
||||
def registered?
|
||||
valid_to >= Time.zone.now
|
||||
end
|
||||
|
||||
def expired?
|
||||
statuses.include?(DomainStatus::EXPIRED)
|
||||
end
|
||||
|
||||
def expirable?
|
||||
return false if valid_to > Time.zone.now
|
||||
|
||||
if expired? && outzone_at.present? && delete_at.present?
|
||||
return false
|
||||
end
|
||||
|
||||
true
|
||||
end
|
||||
end
|
|
@ -250,6 +250,13 @@ class Contact < ActiveRecord::Base
|
|||
kit.to_pdf
|
||||
end
|
||||
|
||||
def names
|
||||
pluck(:name)
|
||||
end
|
||||
|
||||
def emails
|
||||
pluck(:email)
|
||||
end
|
||||
end
|
||||
|
||||
def roid
|
||||
|
|
|
@ -3,12 +3,16 @@ class Domain < ActiveRecord::Base
|
|||
include UserEvents
|
||||
include Versions # version/domain_version.rb
|
||||
include Statuses
|
||||
include Concerns::Domain::Expirable
|
||||
has_paper_trail class_name: "DomainVersion", meta: { children: :children_log }
|
||||
|
||||
attr_accessor :roles
|
||||
|
||||
attr_accessor :legal_document_id
|
||||
|
||||
alias_attribute :on_hold_time, :outzone_at
|
||||
alias_attribute :delete_time, :delete_at
|
||||
|
||||
# TODO: whois requests ip whitelist for full info for own domains and partial info for other domains
|
||||
# TODO: most inputs should be trimmed before validatation, probably some global logic?
|
||||
|
||||
|
@ -746,6 +750,21 @@ class Domain < ActiveRecord::Base
|
|||
DomainMailer.send(action, DomainMailModel.new(self).send(action)).deliver
|
||||
end
|
||||
|
||||
def admin_contact_names
|
||||
admin_contacts.names
|
||||
end
|
||||
|
||||
def admin_contact_emails
|
||||
admin_contacts.emails
|
||||
end
|
||||
|
||||
def tech_contact_names
|
||||
tech_contacts.names
|
||||
end
|
||||
|
||||
def nameserver_hostnames
|
||||
nameservers.hostnames
|
||||
end
|
||||
|
||||
def self.to_csv
|
||||
CSV.generate do |csv|
|
||||
|
|
|
@ -18,7 +18,7 @@ class Nameserver < ActiveRecord::Base
|
|||
before_validation :normalize_attributes
|
||||
before_validation :check_puny_symbols
|
||||
before_validation :check_label_length
|
||||
|
||||
|
||||
delegate :name, to: :domain, prefix: true
|
||||
|
||||
def epp_code_map
|
||||
|
@ -117,5 +117,9 @@ class Nameserver < ActiveRecord::Base
|
|||
# ignoring ips
|
||||
rel
|
||||
end
|
||||
|
||||
def hostnames
|
||||
pluck(:hostname)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
33
app/presenters/domain_presenter.rb
Normal file
33
app/presenters/domain_presenter.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
class DomainPresenter
|
||||
delegate :name, :registrant_name, to: :domain
|
||||
|
||||
def initialize(domain:, view:)
|
||||
@domain = domain
|
||||
@view = view
|
||||
end
|
||||
|
||||
def on_hold_date
|
||||
view.l(domain.on_hold_time, format: :date) if domain.on_hold_time
|
||||
end
|
||||
|
||||
def delete_date
|
||||
view.l(domain.delete_time, format: :date) if domain.delete_time
|
||||
end
|
||||
|
||||
def admin_contact_names
|
||||
domain.admin_contact_names.join(', ')
|
||||
end
|
||||
|
||||
def tech_contact_names
|
||||
domain.tech_contact_names.join(', ')
|
||||
end
|
||||
|
||||
def nameserver_names
|
||||
domain.nameserver_hostnames.join(', ')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
attr_reader :domain
|
||||
attr_reader :view
|
||||
end
|
27
app/presenters/registrar_presenter.rb
Normal file
27
app/presenters/registrar_presenter.rb
Normal file
|
@ -0,0 +1,27 @@
|
|||
class RegistrarPresenter
|
||||
def initialize(registrar:, view:)
|
||||
@registrar = registrar
|
||||
@view = view
|
||||
end
|
||||
|
||||
def name
|
||||
registrar.name
|
||||
end
|
||||
|
||||
def email
|
||||
registrar.email
|
||||
end
|
||||
|
||||
def phone
|
||||
registrar.phone
|
||||
end
|
||||
|
||||
def url
|
||||
registrar.url
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
attr_reader :registrar
|
||||
attr_reader :view
|
||||
end
|
67
app/views/mailers/domain_mailer/expiration.html.erb
Normal file
67
app/views/mailers/domain_mailer/expiration.html.erb
Normal file
|
@ -0,0 +1,67 @@
|
|||
Domeen <%= @domain.name %> on aegunud<br>
|
||||
Lugupeetud .ee domeeni kasutaja<br>
|
||||
<br>
|
||||
Domeeninimi <%= @domain.name %> on aegunud ja ei ole alates <%= @domain.on_hold_date %> internetis kättesaadav. Alates <%= @domain.delete_date %> on domeen <%= @domain.name %> avatud registreerimiseks kõigile huvilistele.
|
||||
<br><br>
|
||||
Domeeni registreeringu pikendamiseks pöörduge palun oma registripidaja <%= @registrar.name %> poole. Registripidajate kontaktid leiate aadressilt www.internet.ee/registripidajad.
|
||||
<br><br>
|
||||
Domeeni <%= @domain.name %> kohta on registris järgmised andmed:
|
||||
<br><br>
|
||||
Registreerija: <%= @domain.registrant_name %><br>
|
||||
Halduskontakt: <%= @domain.admin_contact_names %><br>
|
||||
Tehniline kontakt: <%= @domain.tech_contact_names %><br>
|
||||
Registripidaja: <%= @registrar.name %><br>
|
||||
Nimeserverid: <%= @domain.nameserver_names %><br>
|
||||
Ülevaate kõikidest endaga seotud domeenidest saate registreerija portaalist. <%= ENV['registrant_url'] %>.<br>
|
||||
<br><br>
|
||||
Lugupidamisega<br>
|
||||
Eesti Interneti Sihtasutus
|
||||
<br><br>
|
||||
<hr>
|
||||
<br><br>
|
||||
The <%= @domain.name %> domain has expired<br>
|
||||
Dear user of .ee domain,<br>
|
||||
<br>
|
||||
The domain name <%= @domain.name %> has expired and will not be available on the Internet from <%= @domain.on_hold_date %>. From <%= @domain.delete_date %>, the <%= @domain.name %> domain will be available for registration on a first come first served basis.
|
||||
<br><br>
|
||||
To renew the domain registration, please contact your registrar <%= @registrar.name %>. You can find the registrar's contacts at http://internet.ee/registrars.
|
||||
<br><br>
|
||||
The following data for the <%= @domain.name %> domain have been entered into the registry:
|
||||
<br><br>
|
||||
Registrant: <%= @domain.registrant_name %><br>
|
||||
Administrative contact: <%= @domain.admin_contact_names %><br>
|
||||
Technical contact: <%= @domain.tech_contact_names %><br>
|
||||
Registrar: <%= @registrar.name %><br>
|
||||
Name servers: <%= @domain.nameserver_names %><br>
|
||||
You can find an overview of all your domains at the registrant's portal. <%= ENV['registrant_url'] %>.<br>
|
||||
<br><br>
|
||||
Best Regards,<br>
|
||||
Estonian Internet Foundation
|
||||
<br><br>
|
||||
<hr>
|
||||
<br><br>
|
||||
Домен <%= @domain.name %> устарел<br>
|
||||
Уважаемый пользователь домена .ee<br>
|
||||
<br>
|
||||
|
||||
Доменное имя <%= @domain.name %> устарело и с <%= @domain.on_hold_date %> недоступно в Интернете. С <%= @domain.delete_date %> домен <%= @domain.name %> доступен для регистрации всем желающим по принципу "first come, first served".
|
||||
|
||||
<br><br>
|
||||
|
||||
Для продления регистрации домена просим обратиться к своему регистратору <%= @registrar.name %>. Контактные данные регистраторов можно найти по адресу http://internet.ee/registratory.
|
||||
<br><br>
|
||||
|
||||
Относительно домена <%= @domain.name %> в реестр внесены следующие данные:
|
||||
<br><br>
|
||||
|
||||
Регистрант: <%= @domain.registrant_name %><br>
|
||||
Административный контакт: <%= @domain.admin_contact_names %><br>
|
||||
Технический контакт: <%= @domain.tech_contact_names %><br>
|
||||
Регистратор: <%= @registrar.name %><br>
|
||||
Серверы доменных имен: <%= @domain.nameserver_names %><br>
|
||||
Обзор всех связанных с Вами доменов можете получить на портале регистранта. <%= ENV['registrant_url'] %>.<br>
|
||||
|
||||
<br><br>
|
||||
|
||||
С наилучшими пожеланиями<br>
|
||||
Целевое учреждение Eesti Internet
|
60
app/views/mailers/domain_mailer/expiration.text.erb
Normal file
60
app/views/mailers/domain_mailer/expiration.text.erb
Normal file
|
@ -0,0 +1,60 @@
|
|||
Domeen <%= @domain.name %> on aegunud
|
||||
Lugupeetud .ee domeeni kasutaja
|
||||
|
||||
Domeeninimi <%= @domain.name %> on aegunud ja ei ole alates <%= @domain.on_hold_date %> internetis kättesaadav. Alates <%= @domain.delete_date %> on domeen <%= @domain.name %> avatud registreerimiseks kõigile huvilistele.
|
||||
|
||||
Domeeni registreeringu pikendamiseks pöörduge palun oma registripidaja <%= @registrar.name %> poole. Registripidajate kontaktid leiate aadressilt www.internet.ee/registripidajad.
|
||||
|
||||
Domeeni <%= @domain.name %> kohta on registris järgmised andmed:
|
||||
|
||||
Registreerija: <%= @domain.registrant_name %>
|
||||
Halduskontakt: <%= @domain.admin_contact_names %>
|
||||
Tehniline kontakt: <%= @domain.tech_contact_names %>
|
||||
Registripidaja: <%= @registrar.name %>
|
||||
Nimeserverid: <%= @domain.nameserver_names %>
|
||||
Ülevaate kõikidest endaga seotud domeenidest saate registreerija portaalist. <%= ENV['registrant_url'] %>.
|
||||
|
||||
Parimate soovidega
|
||||
Eesti Interneti Sihtasutus
|
||||
|
||||
--------------------------------------
|
||||
|
||||
The <%= @domain.name %> domain has expired
|
||||
Dear user of .ee domain,
|
||||
|
||||
The domain name <%= @domain.name %> has expired and will not be available on the Internet from <%= @domain.on_hold_date %>. From <%= @domain.delete_date %>, the <%= @domain.name %> domain will be available for registration on a first come first served basis.
|
||||
|
||||
To renew the domain registration, please contact your registrar <%= @registrar.name %>. You can find the registrar's contacts at http://internet.ee/registrars.
|
||||
|
||||
The following data for the <%= @domain.name %> domain have been entered into the registry:
|
||||
|
||||
Registrant: <%= @domain.registrant_name %>
|
||||
Administrative contact: <%= @domain.admin_contact_names %>
|
||||
Technical contact: <%= @domain.tech_contact_names %>
|
||||
Registrar: <%= @registrar.name %>
|
||||
Name servers: <%= @domain.nameserver_names %>
|
||||
You can find an overview of all your domains at the registrant's portal. <%= ENV['registrant_url'] %>.
|
||||
|
||||
Best Regards,
|
||||
Estonian Internet Foundation
|
||||
|
||||
--------------------------------------
|
||||
|
||||
Домен <%= @domain.name %> устарел
|
||||
Уважаемый пользователь домена .ee
|
||||
|
||||
Доменное имя <%= @domain.name %> устарело и с <%= @domain.on_hold_date %> недоступно в Интернете. С <%= @domain.delete_date %> домен <%= @domain.name %> доступен для регистрации всем желающим по принципу "first come, first served".
|
||||
|
||||
Для продления регистрации домена просим обратиться к своему регистратору <%= @registrar.name %>. Контактные данные регистраторов можно найти по адресу http://internet.ee/registratory.
|
||||
|
||||
Относительно домена <%= @domain %> в реестр внесены следующие данные:
|
||||
|
||||
Регистрант: <%= @domain.registrant_name %>
|
||||
Административный контакт: <%= @domain.admin_contact_names %>
|
||||
Технический контакт: <%= @domain.tech_contact_names %>
|
||||
Регистратор: <%= @registrar.name %>
|
||||
Серверы доменных имен: <%= @domain.nameserver_names %>
|
||||
Обзор всех связанных с Вами доменов можете получить на портале регистранта. <%= ENV['registrant_url'] %>.
|
||||
|
||||
С наилучшими пожеланиями
|
||||
Целевое учреждение Eesti Internet
|
Loading…
Add table
Add a link
Reference in a new issue