Skip to content

Commit

Permalink
feat: add support for multiple reserved domains
Browse files Browse the repository at this point in the history
- Add new ReservedDomainsInvoiceStatusesController to handle multiple domains
- Removed ReservedDomainInvoiceStatusesController (single domain)
- Update invoice description to support multiple reserved domain names
- Update Docker configuration:
  - Switch to official Ruby image
  - Update PostgreSQL client version
  - Remove unused Qt and Chrome dependencies

This change enables handling multiple domain reservations in a single invoice
  • Loading branch information
OlegPhenomenon committed Nov 1, 2024
1 parent 14306a7 commit 8a932b6
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 44 deletions.
22 changes: 7 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM internetee/ruby:3.2.2-bullseye
FROM ruby:3.2.2-bullseye

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

Expand All @@ -24,9 +24,9 @@ RUN sed -i -e 's/# et_EE.UTF-8 UTF-8/et_EE.UTF-8 UTF-8/' /etc/locale.gen && \

ENV LANG et_EE.UTF-8
RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc -s | apt-key add -
RUN sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
RUN sh -c 'echo "deb https://apt-archive.postgresql.org/pub/repos/apt bionic-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
RUN apt-get update > /dev/null && apt-get install -y --no-install-recommends > /dev/null \
postgresql-client-13=* \
postgresql-client-11=* \
libpq-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
Expand All @@ -36,12 +36,12 @@ RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -

RUN apt-get install -y --no-install-recommends > /dev/null \
nodejs=* \
qt5-default=* \
libqt5webkit5-dev=* \
# qt5-default=* \
# libqt5webkit5-dev=* \
gstreamer1.0-plugins-base=* \
libappindicator3-1=* \
# libappindicator3-1=* \
gstreamer1.0-tools=* \
qtdeclarative5-dev=* \
# qtdeclarative5-dev=* \
fonts-liberation=* \
gstreamer1.0-x=* \
libasound2=* \
Expand All @@ -62,14 +62,6 @@ RUN apt-get install -y --no-install-recommends > /dev/null \

RUN npm install -g yarn@latest

RUN curl https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -o /chrome.deb
RUN dpkg -i /chrome.deb || apt-get update > /dev/null \
&& apt-get install -yf --no-install-recommends > /dev/null && apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN dpkg -i /chrome.deb
RUN rm /chrome.deb
RUN sed -i 's/SECLEVEL=2/SECLEVEL=1/' /etc/ssl/openssl.cnf

RUN mkdir -p /opt/webapps/app/tmp/pids
WORKDIR /opt/webapps/app

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module Api
module V1
module Invoice
class ReservedDomainsInvoiceStatusesController < ApplicationController
before_action :set_invoice, only: :show

def show
if @invoice.paid?
render json: {
message: 'Domain is reserved',
invoice_status: 'paid',
invoice_number: params[:invoice_number]
},
status: :ok
else
render json: {
message: 'Domains are not reserved',
invoice_status: 'unpaid',
invoice_number: params[:invoice_number]
},
status: :ok
end
end

private

def set_invoice
@invoice = ::Invoice.find_by(invoice_number: params[:invoice_number])

raise ActiveRecord::RecordNotFound, 'Invoice not found' if @invoice.nil?
end
end
end
end
end
4 changes: 2 additions & 2 deletions app/services/invoice_instance_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ class InvoiceInstanceGenerator
REGULAR = 'regular'.freeze

def self.create(params:)
description = if params[:reserved_domain_name].present? && params[:token].present?
"Reserved domain name: #{params[:reserved_domain_name]}, Token: #{params[:token]}"
description = if params[:reserved_domain_names].present?
"Reserved domain names: #{params[:reserved_domain_names].join(', ')}"
else
params.fetch(:custom_field1, 'reload balance').to_s
end
Expand Down
3 changes: 2 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
namespace :invoice do
resource :invoice_synchronize, only: :update
resource :update_invoice_data, only: :update
resource :reserved_domain_invoice_statuses, only: :show
resource :reserved_domain_invoice_statuses, only: :show # deprecated
resource :reserved_domains_invoice_statuses, only: :show
resource :reserved_domain_cancellation_statuses, only: :update
end

Expand Down

0 comments on commit 8a932b6

Please sign in to comment.