Merge branch 'master' into registry-887-revoke-certificate-before-removing-it

This commit is contained in:
Maciej Szlosarczyk 2018-09-20 16:08:18 +03:00
commit 24b87d8592
No known key found for this signature in database
GPG key ID: 41D62D42D3B0D765
70 changed files with 611 additions and 449 deletions

View file

@ -1,5 +1,3 @@
require 'csv'
class AccountActivity < ActiveRecord::Base
include Versions
belongs_to :account, required: true

View file

@ -81,8 +81,8 @@ class ApiUser < User
username
end
def queued_messages
registrar.messages.queued
def unread_notifications
registrar.notifications.unread
end
def registrar_pki_ok?(crt, cn)

View file

@ -265,9 +265,9 @@ class Domain < ActiveRecord::Base
true
end
def poll_message!(message_key)
registrar.messages.create!(
body: "#{I18n.t(message_key)}: #{name}",
def notify_registrar(message_key)
registrar.notifications.create!(
text: "#{I18n.t(message_key)}: #{name}",
attached_obj_id: id,
attached_obj_type: self.class.to_s
)

View file

@ -73,8 +73,8 @@ class DomainTransfer < ActiveRecord::Base
old_contacts_codes = domain.contacts.pluck(:code).sort.uniq.join(', ')
old_registrant_code = domain.registrant.code
old_registrar.messages.create!(
body: I18n.t('messages.texts.domain_transfer',
old_registrar.notifications.create!(
text: I18n.t('notifications.texts.domain_transfer',
domain_name: domain.name,
old_contacts_codes: old_contacts_codes,
old_registrant_code: old_registrant_code),

View file

@ -625,8 +625,8 @@ class Epp::Domain < Domain
)
if dt.pending?
registrar.messages.create!(
body: I18n.t('transfer_requested'),
registrar.notifications.create!(
text: I18n.t('transfer_requested'),
attached_obj_id: dt.id,
attached_obj_type: dt.class.to_s
)
@ -727,8 +727,8 @@ class Epp::Domain < Domain
return false unless valid?
registrar.messages.create!(
body: 'Key Relay action completed successfully.',
registrar.notifications.create!(
text: 'Key Relay action completed successfully.',
attached_obj_type: kr.class.to_s,
attached_obj_id: kr.id
)

View file

@ -1,19 +0,0 @@
class Message < ActiveRecord::Base
include Versions # version/message_version.rb
belongs_to :registrar, required: true
before_create -> { self.queued = true }
scope :queued, -> { where(queued: true) }
validates :body, presence: true
def dequeue
self.queued = false
save
end
def name
"-"
end
end

View file

@ -0,0 +1,31 @@
class Notification < ActiveRecord::Base
include Versions # version/notification_version.rb
belongs_to :registrar
scope :unread, -> { where(read: false) }
validates :text, presence: true
after_initialize :set_defaults
def mark_as_read
raise 'Read notification cannot be marked as read again' if read?
self.read = true
save
end
def unread?
!read?
end
# Needed for EPP log
def name
"-"
end
private
def set_defaults
self.read = false if read.nil?
end
end

View file

@ -4,7 +4,7 @@ class Registrar < ActiveRecord::Base
has_many :domains, dependent: :restrict_with_error
has_many :contacts, dependent: :restrict_with_error
has_many :api_users, dependent: :restrict_with_error
has_many :messages
has_many :notifications
has_many :invoices, foreign_key: 'buyer_id'
has_many :accounts, dependent: :destroy
has_many :nameservers, through: :domains

View file

@ -1,5 +0,0 @@
class MessageVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_messages
self.sequence_name = :log_messages_id_seq
end

View file

@ -0,0 +1,5 @@
class NotificationVersion < PaperTrail::Version
include VersionSession
self.table_name = :log_notifications
self.sequence_name = :log_notifications_id_seq
end