From a864056fbd1733bc2d940d288911b41d093fa4df Mon Sep 17 00:00:00 2001 From: oleghasjanov Date: Thu, 17 Jul 2025 15:04:48 +0300 Subject: [PATCH 1/3] feat(admin): notify registrar about domain status changes - Add inform_registrar_about_status_changes method to detect added and removed statuses after domain update. - Send notification to registrar with details of which statuses were set and which were removed. - Integrate notification logic into domain update action. --- app/controllers/admin/domains_controller.rb | 15 ++++++++++++++ test/integration/domain/domain_test.rb | 22 +++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 test/integration/domain/domain_test.rb diff --git a/app/controllers/admin/domains_controller.rb b/app/controllers/admin/domains_controller.rb index 0e9279a46..1da1bbc08 100644 --- a/app/controllers/admin/domains_controller.rb +++ b/app/controllers/admin/domains_controller.rb @@ -31,6 +31,7 @@ module Admin if @domain.update(dp) flash[:notice] = I18n.t('domain_updated') + inform_registrar_about_status_changes redirect_to [:admin, @domain] else @domain.reload @@ -111,6 +112,20 @@ module Admin end end + def inform_registrar_about_status_changes + return unless @domain.saved_change_to_statuses? + + old_statuses, new_statuses = @domain.saved_change_to_statuses + removed = old_statuses - new_statuses + added = new_statuses - old_statuses + + msg = [] + msg << "Set on #{@domain.name}: #{added.join(', ')}" unless added.empty? + msg << "Removed from #{@domain.name}: #{removed.join(', ')}" unless removed.empty? + + @domain.registrar.notifications.create!(text: msg.join('. ')) if msg.any? + end + def build_associations @server_statuses = @domain.statuses.select { |x| DomainStatus::SERVER_STATUSES.include?(x) } @server_statuses = [nil] if @server_statuses.empty? diff --git a/test/integration/domain/domain_test.rb b/test/integration/domain/domain_test.rb new file mode 100644 index 000000000..387f6bc03 --- /dev/null +++ b/test/integration/domain/domain_test.rb @@ -0,0 +1,22 @@ +require 'test_helper' + +class DomainTest < ApplicationIntegrationTest + + def setup + @domain = domains(:shop) + @admin = users(:admin) + sign_in @admin + end + + def test_inform_registrar_about_status_changes + patch admin_domain_path(domains(:shop)), params: { domain: { statuses: [DomainStatus::PENDING_UPDATE,] } } + + # Status OK is removed because, if: + # (statuses.length > 1) || !valid? + # then status OK is removed by manage_automatic_statuses method in domain.rb + assert_equal "Set on #{domains(:shop).name}: #{DomainStatus::PENDING_UPDATE}. Removed from #{domains(:shop).name}: #{DomainStatus::OK}", domains(:shop).registrar.notifications.last.text + + patch admin_domain_path(domains(:shop)), params: { domain: { statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION] } } + assert_equal "Set on #{domains(:shop).name}: #{DomainStatus::PENDING_DELETE_CONFIRMATION}. Removed from #{domains(:shop).name}: #{DomainStatus::PENDING_UPDATE}", domains(:shop).registrar.notifications.last.text + end +end From 682d9f6de18e8bbb0d4b737391e99a8325be820a Mon Sep 17 00:00:00 2001 From: oleghasjanov Date: Thu, 17 Jul 2025 15:17:34 +0300 Subject: [PATCH 2/3] rename domain controller test --- .../domain/{domain_test.rb => domains_controller_test.rb} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename test/integration/domain/{domain_test.rb => domains_controller_test.rb} (94%) diff --git a/test/integration/domain/domain_test.rb b/test/integration/domain/domains_controller_test.rb similarity index 94% rename from test/integration/domain/domain_test.rb rename to test/integration/domain/domains_controller_test.rb index 387f6bc03..c82e46808 100644 --- a/test/integration/domain/domain_test.rb +++ b/test/integration/domain/domains_controller_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class DomainTest < ApplicationIntegrationTest +class DomainsControllerTest < ApplicationIntegrationTest def setup @domain = domains(:shop) From 7343e710964a8b97d1f93a410c67e956cc9a06ee Mon Sep 17 00:00:00 2001 From: oleghasjanov Date: Thu, 31 Jul 2025 13:54:58 +0300 Subject: [PATCH 3/3] made poll messaging separetly --- Dockerfile | 40 +++++++++---------- app/controllers/admin/domains_controller.rb | 10 +++-- .../domain/domains_controller_test.rb | 8 +++- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/Dockerfile b/Dockerfile index 710ce6316..bbfac955e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=linux/amd64 ruby:3.0.3-slim-buster +FROM --platform=linux/amd64 ruby:3.0.3-bullseye SHELL ["/bin/bash", "-o", "pipefail", "-c"] RUN apt-get update > /dev/null && apt-get install -y --no-install-recommends > /dev/null \ @@ -29,27 +29,27 @@ RUN apt-get update > /dev/null && apt-get install -y --no-install-recommends > / && rm -rf /var/lib/apt/lists/* # add repository for Node.js in the LTS version -RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - +RUN curl -sL https://deb.nodesource.com/setup_20.x | bash - RUN apt-get install -y --no-install-recommends > /dev/null \ - nodejs=* \ - qt5-default=* \ - libqt5webkit5-dev=* \ - gstreamer1.0-plugins-base=* \ - libappindicator3-1=* \ - gstreamer1.0-tools=* \ - qtdeclarative5-dev=* \ - fonts-liberation=* \ - gstreamer1.0-x=* \ - libasound2=* \ - libnspr4=* \ - libnss3=* \ - libxss1=* \ - libxtst6=* \ - xdg-utils=* \ - qtdeclarative5-dev=* \ - fonts-liberation=* \ - gstreamer1.0-x=* \ + nodejs \ + qtbase5-dev \ + libqt5webkit5-dev \ + gstreamer1.0-plugins-base \ + libappindicator3-1 \ + gstreamer1.0-tools \ + qtdeclarative5-dev \ + fonts-liberation \ + gstreamer1.0-x \ + libasound2 \ + libnspr4 \ + libnss3 \ + libxss1 \ + libxtst6 \ + xdg-utils \ + qtdeclarative5-dev \ + fonts-liberation \ + gstreamer1.0-x \ wkhtmltopdf \ libxslt1-dev \ libxml2-dev \ diff --git a/app/controllers/admin/domains_controller.rb b/app/controllers/admin/domains_controller.rb index 1da1bbc08..d507b1326 100644 --- a/app/controllers/admin/domains_controller.rb +++ b/app/controllers/admin/domains_controller.rb @@ -119,11 +119,13 @@ module Admin removed = old_statuses - new_statuses added = new_statuses - old_statuses - msg = [] - msg << "Set on #{@domain.name}: #{added.join(', ')}" unless added.empty? - msg << "Removed from #{@domain.name}: #{removed.join(', ')}" unless removed.empty? + added.each do |status| + @domain.registrar.notifications.create!(text: "#{status} set on domain #{@domain.name}") + end - @domain.registrar.notifications.create!(text: msg.join('. ')) if msg.any? + removed.each do |status| + @domain.registrar.notifications.create!(text: "#{status} is cancelled on domain #{@domain.name}") + end end def build_associations diff --git a/test/integration/domain/domains_controller_test.rb b/test/integration/domain/domains_controller_test.rb index c82e46808..ac2d55d7d 100644 --- a/test/integration/domain/domains_controller_test.rb +++ b/test/integration/domain/domains_controller_test.rb @@ -14,9 +14,13 @@ class DomainsControllerTest < ApplicationIntegrationTest # Status OK is removed because, if: # (statuses.length > 1) || !valid? # then status OK is removed by manage_automatic_statuses method in domain.rb - assert_equal "Set on #{domains(:shop).name}: #{DomainStatus::PENDING_UPDATE}. Removed from #{domains(:shop).name}: #{DomainStatus::OK}", domains(:shop).registrar.notifications.last.text + notifications = domains(:shop).registrar.notifications.last(2) + assert_equal "#{DomainStatus::PENDING_UPDATE} set on domain #{domains(:shop).name}", notifications.first.text + assert_equal "#{DomainStatus::OK} is cancelled on domain #{domains(:shop).name}", notifications.last.text patch admin_domain_path(domains(:shop)), params: { domain: { statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION] } } - assert_equal "Set on #{domains(:shop).name}: #{DomainStatus::PENDING_DELETE_CONFIRMATION}. Removed from #{domains(:shop).name}: #{DomainStatus::PENDING_UPDATE}", domains(:shop).registrar.notifications.last.text + notifications = domains(:shop).registrar.notifications.last(2) + assert_equal "#{DomainStatus::PENDING_DELETE_CONFIRMATION} set on domain #{domains(:shop).name}", notifications.first.text + assert_equal "#{DomainStatus::PENDING_UPDATE} is cancelled on domain #{domains(:shop).name}", notifications.last.text end end