mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 17:28:18 +02:00
Rename Message to Notification
This commit is contained in:
parent
5ba2170324
commit
8765baf319
32 changed files with 243 additions and 229 deletions
|
@ -6,7 +6,8 @@ module Admin
|
|||
|
||||
domain.transaction do
|
||||
domain.schedule_force_delete
|
||||
domain.registrar.messages.create!(body: t('force_delete_set_on_domain', domain_name: domain.name))
|
||||
domain.registrar.notifications.create!(body: t('force_delete_set_on_domain',
|
||||
domain_name: domain.name))
|
||||
|
||||
if notify_by_email?
|
||||
DomainDeleteMailer.forced(domain: domain,
|
||||
|
|
|
@ -9,12 +9,12 @@ class Epp::PollsController < EppController
|
|||
private
|
||||
|
||||
def req_poll
|
||||
@message = current_user.queued_messages.last
|
||||
@notification = current_user.queued_notifications.last
|
||||
|
||||
render_epp_response 'epp/poll/poll_no_messages' and return unless @message
|
||||
if @message.attached_obj_type && @message.attached_obj_id
|
||||
render_epp_response 'epp/poll/poll_no_messages' and return unless @notification
|
||||
if @notification.attached_obj_type && @notification.attached_obj_id
|
||||
begin
|
||||
@object = Object.const_get(@message.attached_obj_type).find(@message.attached_obj_id)
|
||||
@object = Object.const_get(@notification.attached_obj_type).find(@notification.attached_obj_id)
|
||||
rescue => problem
|
||||
# the data model might be inconsistent; or ...
|
||||
# this could happen if the registrar does not dequeue messages, and then the domain was deleted
|
||||
|
@ -28,7 +28,7 @@ class Epp::PollsController < EppController
|
|||
end
|
||||
end
|
||||
|
||||
if @message.attached_obj_type == 'Keyrelay'
|
||||
if @notification.attached_obj_type == 'Keyrelay'
|
||||
render_epp_response 'epp/poll/poll_keyrelay'
|
||||
else
|
||||
render_epp_response 'epp/poll/poll_req'
|
||||
|
@ -36,9 +36,9 @@ class Epp::PollsController < EppController
|
|||
end
|
||||
|
||||
def ack_poll
|
||||
@message = current_user.queued_messages.find_by(id: params[:parsed_frame].css('poll').first['msgID'])
|
||||
@notification = current_user.queued_notifications.find_by(id: params[:parsed_frame].css('poll').first['msgID'])
|
||||
|
||||
unless @message
|
||||
unless @notification
|
||||
epp_errors << {
|
||||
code: '2303',
|
||||
msg: I18n.t('message_was_not_found'),
|
||||
|
@ -47,7 +47,7 @@ class Epp::PollsController < EppController
|
|||
handle_errors and return
|
||||
end
|
||||
|
||||
handle_errors(@message) and return unless @message.dequeue
|
||||
handle_errors(@notification) and return unless @notification.dequeue
|
||||
render_epp_response 'epp/poll/poll_ack'
|
||||
end
|
||||
|
||||
|
@ -56,6 +56,6 @@ class Epp::PollsController < EppController
|
|||
end
|
||||
|
||||
def resource
|
||||
@message
|
||||
@notification
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,13 +7,13 @@ class DomainDeleteConfirmJob < Que::Job
|
|||
|
||||
case action
|
||||
when RegistrantVerification::CONFIRMED
|
||||
domain.poll_message!(:poll_pending_delete_confirmed_by_registrant)
|
||||
domain.notify_registrar(:poll_pending_delete_confirmed_by_registrant)
|
||||
domain.apply_pending_delete!
|
||||
raise_errors!(domain)
|
||||
|
||||
when RegistrantVerification::REJECTED
|
||||
domain.statuses.delete(DomainStatus::PENDING_DELETE_CONFIRMATION)
|
||||
domain.poll_message!(:poll_pending_delete_rejected_by_registrant)
|
||||
domain.notify_registrar(:poll_pending_delete_rejected_by_registrant)
|
||||
|
||||
domain.cancel_pending_delete
|
||||
domain.save(validate: false)
|
||||
|
|
|
@ -8,7 +8,7 @@ class DomainDeleteJob < Que::Job
|
|||
|
||||
domain.destroy
|
||||
bye_bye = domain.versions.last
|
||||
domain.registrar.messages.create!(
|
||||
domain.registrar.notifications.create!(
|
||||
body: "#{I18n.t(:domain_deleted)}: #{domain.name}",
|
||||
attached_obj_id: bye_bye.id,
|
||||
attached_obj_type: bye_bye.class.to_s
|
||||
|
|
|
@ -8,7 +8,7 @@ class DomainUpdateConfirmJob < Que::Job
|
|||
case action
|
||||
when RegistrantVerification::CONFIRMED
|
||||
old_registrant = domain.registrant
|
||||
domain.poll_message!(:poll_pending_update_confirmed_by_registrant)
|
||||
domain.notify_registrar(:poll_pending_update_confirmed_by_registrant)
|
||||
raise_errors!(domain)
|
||||
|
||||
domain.apply_pending_update!
|
||||
|
@ -22,7 +22,7 @@ class DomainUpdateConfirmJob < Que::Job
|
|||
registrar: domain.registrar,
|
||||
registrant: domain.registrant).deliver_now
|
||||
|
||||
domain.poll_message!(:poll_pending_update_rejected_by_registrant)
|
||||
domain.notify_registrar(:poll_pending_update_rejected_by_registrant)
|
||||
|
||||
domain.preclean_pendings
|
||||
domain.clean_pendings!
|
||||
|
|
|
@ -79,8 +79,8 @@ class ApiUser < User
|
|||
username
|
||||
end
|
||||
|
||||
def queued_messages
|
||||
registrar.messages.queued
|
||||
def queued_notifications
|
||||
registrar.notifications.queued
|
||||
end
|
||||
|
||||
def registrar_pki_ok?(crt, cn)
|
||||
|
|
|
@ -270,8 +270,8 @@ class Domain < ActiveRecord::Base
|
|||
true
|
||||
end
|
||||
|
||||
def poll_message!(message_key)
|
||||
registrar.messages.create!(
|
||||
def notify_registrar(message_key)
|
||||
registrar.notifications.create!(
|
||||
body: "#{I18n.t(message_key)}: #{name}",
|
||||
attached_obj_id: id,
|
||||
attached_obj_type: self.class.to_s
|
||||
|
|
|
@ -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!(
|
||||
body: I18n.t('notifications.texts.domain_transfer',
|
||||
domain_name: domain.name,
|
||||
old_contacts_codes: old_contacts_codes,
|
||||
old_registrant_code: old_registrant_code),
|
||||
|
|
|
@ -625,7 +625,7 @@ class Epp::Domain < Domain
|
|||
)
|
||||
|
||||
if dt.pending?
|
||||
registrar.messages.create!(
|
||||
registrar.notifications.create!(
|
||||
body: I18n.t('transfer_requested'),
|
||||
attached_obj_id: dt.id,
|
||||
attached_obj_type: dt.class.to_s
|
||||
|
@ -727,7 +727,7 @@ class Epp::Domain < Domain
|
|||
|
||||
return false unless valid?
|
||||
|
||||
registrar.messages.create!(
|
||||
registrar.notifications.create!(
|
||||
body: 'Key Relay action completed successfully.',
|
||||
attached_obj_type: kr.class.to_s,
|
||||
attached_obj_id: kr.id
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class Message < ActiveRecord::Base
|
||||
include Versions # version/message_version.rb
|
||||
class Notification < ActiveRecord::Base
|
||||
include Versions # version/notification_version.rb
|
||||
belongs_to :registrar, required: true
|
||||
|
||||
before_create -> { self.queued = true }
|
|
@ -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
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
class MessageVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_messages
|
||||
self.sequence_name = :log_messages_id_seq
|
||||
end
|
5
app/models/version/notification_version.rb
Normal file
5
app/models/version/notification_version.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class NotificationVersion < PaperTrail::Version
|
||||
include VersionSession
|
||||
self.table_name = :log_notifications
|
||||
self.sequence_name = :log_notifications_id_seq
|
||||
end
|
|
@ -4,7 +4,7 @@ xml.epp_head do
|
|||
xml.msg 'Command completed successfully'
|
||||
end
|
||||
|
||||
xml.tag!('msgQ', 'count' => current_user.queued_messages.count, 'id' => @message.id)
|
||||
xml.tag!('msgQ', 'count' => current_user.queued_notifications.count, 'id' => @notification.id)
|
||||
|
||||
render('epp/shared/trID', builder: xml)
|
||||
end
|
||||
|
|
|
@ -10,9 +10,9 @@ xml.epp(
|
|||
xml.msg 'Command completed successfully; ack to dequeue'
|
||||
end
|
||||
|
||||
xml.tag!('msgQ', 'count' => current_user.queued_messages.count, 'id' => @message.id) do
|
||||
xml.qDate @message.created_at.try(:iso8601)
|
||||
xml.msg @message.body
|
||||
xml.tag!('msgQ', 'count' => current_user.queued_notifications.count, 'id' => @notification.id) do
|
||||
xml.qDate @notification.created_at.try(:iso8601)
|
||||
xml.msg @notification.body
|
||||
end
|
||||
|
||||
xml.resData do
|
||||
|
|
|
@ -4,12 +4,12 @@ xml.epp_head do
|
|||
xml.msg 'Command completed successfully; ack to dequeue'
|
||||
end
|
||||
|
||||
xml.tag!('msgQ', 'count' => current_user.queued_messages.count, 'id' => @message.id) do
|
||||
xml.qDate @message.created_at.try(:iso8601)
|
||||
xml.msg @message.body
|
||||
xml.tag!('msgQ', 'count' => current_user.queued_notifications.count, 'id' => @notification.id) do
|
||||
xml.qDate @notification.created_at.try(:iso8601)
|
||||
xml.msg @notification.body
|
||||
end
|
||||
|
||||
if @message.attached_obj_type == 'DomainTransfer'
|
||||
if @notification.attached_obj_type == 'DomainTransfer'
|
||||
xml.resData do
|
||||
xml << render('epp/domains/partials/transfer', builder: xml, dt: @object)
|
||||
end if @object
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue