mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 17:28:18 +02:00
Improve domain expiring logic #2909
This commit is contained in:
parent
58249742c1
commit
7064a4b9bc
4 changed files with 46 additions and 24 deletions
|
@ -230,7 +230,7 @@ class Domain < ActiveRecord::Base
|
|||
domains = Domain.where('valid_to <= ?', Time.zone.now)
|
||||
domains.each do |domain|
|
||||
next unless domain.expirable?
|
||||
domain.set_expired
|
||||
domain.set_graceful_expired
|
||||
STDOUT << "#{Time.zone.now.utc} Domain.start_expire_period: ##{domain.id} #{domain.changes}\n" unless Rails.env.test?
|
||||
domain.save(validate: false)
|
||||
end
|
||||
|
@ -320,7 +320,12 @@ class Domain < ActiveRecord::Base
|
|||
|
||||
def expirable?
|
||||
return false if valid_to > Time.zone.now
|
||||
!statuses.include?(DomainStatus::EXPIRED)
|
||||
|
||||
if statuses.include?(DomainStatus::EXPIRED) && outzone_at.present? && delete_at.present?
|
||||
return false
|
||||
end
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
def server_holdable?
|
||||
|
@ -545,8 +550,6 @@ class Domain < ActiveRecord::Base
|
|||
self.registered_at = Time.zone.now
|
||||
self.valid_from = Time.zone.now
|
||||
self.valid_to = valid_from + self.class.convert_period_to_time(period, period_unit)
|
||||
self.outzone_at = valid_to + Setting.expire_warning_period.days
|
||||
self.delete_at = outzone_at + Setting.redemption_grace_period.days
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
|
@ -603,6 +606,13 @@ class Domain < ActiveRecord::Base
|
|||
save(validate: false)
|
||||
end
|
||||
|
||||
def set_graceful_expired
|
||||
self.outzone_at = valid_to + Setting.expire_warning_period.days
|
||||
self.delete_at = outzone_at + Setting.redemption_grace_period.days
|
||||
statuses << DomainStatus::EXPIRED
|
||||
end
|
||||
|
||||
# TODO: This looks odd - outzone_at and delete_at will be the same value?
|
||||
def set_expired
|
||||
# TODO: currently valid_to attribute update logic is open
|
||||
# self.valid_to = valid_from + self.class.convert_period_to_time(period, period_unit)
|
||||
|
@ -675,7 +685,6 @@ class Domain < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def manage_automatic_statuses
|
||||
# domain_statuses.create(value: DomainStatus::DELETE_CANDIDATE) if delete_candidateable?
|
||||
if statuses.empty? && valid?
|
||||
statuses << DomainStatus::OK
|
||||
elsif statuses.length > 1 || !valid?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue