mirror of
https://github.com/internetee/registry.git
synced 2025-08-06 09:45:11 +02:00
Merge pull request #1881 from internetee/1880-returns-command-failed-for-transfer-request-with-invalid-legaldoc
Fix error message on too big LegalDoc size in epp
This commit is contained in:
commit
51e5439fa0
3 changed files with 114 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
|||
class LegalDocument < ApplicationRecord
|
||||
include EppErrors
|
||||
MIN_BODY_SIZE = (1.37 * 3.kilobytes).ceil
|
||||
MAX_BODY_SIZE = 8.megabytes
|
||||
|
||||
if ENV['legal_document_types'].present?
|
||||
TYPES = ENV['legal_document_types'].split(',').map(&:strip)
|
||||
|
@ -20,14 +21,19 @@ class LegalDocument < ApplicationRecord
|
|||
|
||||
def epp_code_map
|
||||
{
|
||||
'2306' => [
|
||||
[:body, :length]
|
||||
]
|
||||
'2308' => [
|
||||
%i[body length_more_than],
|
||||
%i[body length_less_than],
|
||||
]
|
||||
}
|
||||
end
|
||||
|
||||
def val_body_length
|
||||
errors.add(:body, :length) if body.nil? || body.size < MIN_BODY_SIZE
|
||||
if body.nil? || body.size < MIN_BODY_SIZE
|
||||
errors.add(:body, :length_more_than)
|
||||
elsif body.size > MAX_BODY_SIZE
|
||||
errors.add(:body, :length_less_than)
|
||||
end
|
||||
end
|
||||
|
||||
def save_to_filesystem
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue