mirror of
https://github.com/internetee/registry.git
synced 2025-08-11 03:59:33 +02:00
Update company_register gem and fix logger dependency
- Switch company_register gem to 'issues-with-upcoming-data' branch - Add concurrent-ruby 1.3.4 to fix ThreadSafeLevel logger error - Update various gem dependencies Resolves logger initialization error related to ActiveSupport::Logger::ThreadSafeLevel
This commit is contained in:
parent
c81aed0c62
commit
d3d91b5294
3 changed files with 117 additions and 12 deletions
5
Gemfile
5
Gemfile
|
@ -69,7 +69,7 @@ gem 'redis'
|
||||||
gem 'sidekiq', '~> 7.0'
|
gem 'sidekiq', '~> 7.0'
|
||||||
|
|
||||||
gem 'company_register', github: 'internetee/company_register',
|
gem 'company_register', github: 'internetee/company_register',
|
||||||
branch: '4-check-for-company-existence'
|
branch: 'issues-with-upcoming-data'
|
||||||
gem 'domain_name'
|
gem 'domain_name'
|
||||||
gem 'e_invoice', github: 'internetee/e_invoice', branch: :master
|
gem 'e_invoice', github: 'internetee/e_invoice', branch: :master
|
||||||
gem 'haml', '~> 6.0'
|
gem 'haml', '~> 6.0'
|
||||||
|
@ -108,3 +108,6 @@ gem 'pg_query', '>= 0.9.0'
|
||||||
# token
|
# token
|
||||||
gem 'jwt'
|
gem 'jwt'
|
||||||
gem 'net-ftp'
|
gem 'net-ftp'
|
||||||
|
|
||||||
|
# https://stackoverflow.com/questions/79360526/uninitialized-constant-activesupportloggerthreadsafelevellogger-nameerror
|
||||||
|
gem 'concurrent-ruby', '1.3.4'
|
||||||
|
|
31
Gemfile.lock
31
Gemfile.lock
|
@ -1,7 +1,7 @@
|
||||||
GIT
|
GIT
|
||||||
remote: https://github.com/internetee/company_register.git
|
remote: https://github.com/internetee/company_register.git
|
||||||
revision: 6465d5c49478b9de5a5fa009cb6b8123b3956dd1
|
revision: 1e91fec78212d7e549a1c2362c011761a447bbcd
|
||||||
branch: 4-check-for-company-existence
|
branch: issues-with-upcoming-data
|
||||||
specs:
|
specs:
|
||||||
company_register (0.1.0)
|
company_register (0.1.0)
|
||||||
activesupport
|
activesupport
|
||||||
|
@ -170,7 +170,7 @@ GEM
|
||||||
aws-eventstream (~> 1, >= 1.0.2)
|
aws-eventstream (~> 1, >= 1.0.2)
|
||||||
base64 (0.2.0)
|
base64 (0.2.0)
|
||||||
bcrypt (3.1.16)
|
bcrypt (3.1.16)
|
||||||
bigdecimal (3.1.8)
|
bigdecimal (3.1.9)
|
||||||
bindata (2.5.0)
|
bindata (2.5.0)
|
||||||
bootsnap (1.17.1)
|
bootsnap (1.17.1)
|
||||||
msgpack (~> 1.2)
|
msgpack (~> 1.2)
|
||||||
|
@ -270,7 +270,7 @@ GEM
|
||||||
mutex_m
|
mutex_m
|
||||||
nkf
|
nkf
|
||||||
rack (>= 2.0, < 4)
|
rack (>= 2.0, < 4)
|
||||||
i18n (1.14.6)
|
i18n (1.14.7)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
i18n_data (0.13.0)
|
i18n_data (0.13.0)
|
||||||
isikukood (0.1.2)
|
isikukood (0.1.2)
|
||||||
|
@ -282,7 +282,7 @@ GEM
|
||||||
thor (>= 0.14, < 2.0)
|
thor (>= 0.14, < 2.0)
|
||||||
jquery-ui-rails (6.0.1)
|
jquery-ui-rails (6.0.1)
|
||||||
railties (>= 3.2.16)
|
railties (>= 3.2.16)
|
||||||
json (2.5.1)
|
json (2.9.1)
|
||||||
json-jwt (1.16.6)
|
json-jwt (1.16.6)
|
||||||
activesupport (>= 4.2)
|
activesupport (>= 4.2)
|
||||||
aes_key_wrap
|
aes_key_wrap
|
||||||
|
@ -304,12 +304,15 @@ GEM
|
||||||
kaminari-core (= 1.2.1)
|
kaminari-core (= 1.2.1)
|
||||||
kaminari-core (1.2.1)
|
kaminari-core (1.2.1)
|
||||||
libxml-ruby (3.2.1)
|
libxml-ruby (3.2.1)
|
||||||
logger (1.4.3)
|
logger (1.6.5)
|
||||||
loofah (2.24.0)
|
loofah (2.24.0)
|
||||||
crass (~> 1.0.2)
|
crass (~> 1.0.2)
|
||||||
nokogiri (>= 1.12.0)
|
nokogiri (>= 1.12.0)
|
||||||
mail (2.7.1)
|
mail (2.8.1)
|
||||||
mini_mime (>= 0.1.1)
|
mini_mime (>= 0.1.1)
|
||||||
|
net-imap
|
||||||
|
net-pop
|
||||||
|
net-smtp
|
||||||
marcel (1.0.4)
|
marcel (1.0.4)
|
||||||
matrix (0.4.2)
|
matrix (0.4.2)
|
||||||
method_source (1.1.0)
|
method_source (1.1.0)
|
||||||
|
@ -321,7 +324,7 @@ GEM
|
||||||
rake
|
rake
|
||||||
mini_mime (1.1.5)
|
mini_mime (1.1.5)
|
||||||
mini_portile2 (2.8.8)
|
mini_portile2 (2.8.8)
|
||||||
minitest (5.25.1)
|
minitest (5.25.4)
|
||||||
minitest-stub_any_instance (1.0.3)
|
minitest-stub_any_instance (1.0.3)
|
||||||
monetize (1.9.4)
|
monetize (1.9.4)
|
||||||
money (~> 6.12)
|
money (~> 6.12)
|
||||||
|
@ -333,12 +336,17 @@ GEM
|
||||||
money (~> 6.13.2)
|
money (~> 6.13.2)
|
||||||
railties (>= 3.0)
|
railties (>= 3.0)
|
||||||
msgpack (1.7.2)
|
msgpack (1.7.2)
|
||||||
mutex_m (0.2.0)
|
mutex_m (0.3.0)
|
||||||
net-ftp (0.3.7)
|
net-ftp (0.3.7)
|
||||||
net-protocol
|
net-protocol
|
||||||
time
|
time
|
||||||
net-http (0.6.0)
|
net-http (0.6.0)
|
||||||
uri
|
uri
|
||||||
|
net-imap (0.4.18)
|
||||||
|
date
|
||||||
|
net-protocol
|
||||||
|
net-pop (0.1.2)
|
||||||
|
net-protocol
|
||||||
net-protocol (0.1.3)
|
net-protocol (0.1.3)
|
||||||
timeout
|
timeout
|
||||||
net-smtp (0.3.3)
|
net-smtp (0.3.3)
|
||||||
|
@ -452,7 +460,7 @@ GEM
|
||||||
http-cookie (>= 1.0.2, < 2.0)
|
http-cookie (>= 1.0.2, < 2.0)
|
||||||
mime-types (>= 1.16, < 4.0)
|
mime-types (>= 1.16, < 4.0)
|
||||||
netrc (~> 0.8)
|
netrc (~> 0.8)
|
||||||
rexml (3.3.9)
|
rexml (3.4.0)
|
||||||
rubyzip (2.3.2)
|
rubyzip (2.3.2)
|
||||||
sass-rails (6.0.0)
|
sass-rails (6.0.0)
|
||||||
sassc-rails (~> 2.1, >= 2.1.1)
|
sassc-rails (~> 2.1, >= 2.1.1)
|
||||||
|
@ -534,7 +542,7 @@ GEM
|
||||||
simpleidn
|
simpleidn
|
||||||
warden (1.2.9)
|
warden (1.2.9)
|
||||||
rack (>= 2.0.9)
|
rack (>= 2.0.9)
|
||||||
wasabi (5.0.3)
|
wasabi (5.1.0)
|
||||||
addressable
|
addressable
|
||||||
faraday (>= 1.9, < 3)
|
faraday (>= 1.9, < 3)
|
||||||
nokogiri (>= 1.13.9)
|
nokogiri (>= 1.13.9)
|
||||||
|
@ -571,6 +579,7 @@ DEPENDENCIES
|
||||||
capybara (~> 3.40.0)
|
capybara (~> 3.40.0)
|
||||||
coffee-rails (>= 5.0)
|
coffee-rails (>= 5.0)
|
||||||
company_register!
|
company_register!
|
||||||
|
concurrent-ruby (= 1.3.4)
|
||||||
countries
|
countries
|
||||||
data_migrate (~> 9.0)
|
data_migrate (~> 9.0)
|
||||||
database_cleaner
|
database_cleaner
|
||||||
|
|
93
app/jobs/org_registrant_phone_checker_job.rb
Normal file
93
app/jobs/org_registrant_phone_checker_job.rb
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
class OrgRegistrantPhoneCheckerJob < ApplicationJob
|
||||||
|
queue_as :default
|
||||||
|
|
||||||
|
def perform(type: 'bulk', registrant_user_code: nil, spam_delay: 1 )
|
||||||
|
case type
|
||||||
|
when 'bulk'
|
||||||
|
execute_bulk_checker(spam_delay)
|
||||||
|
when 'single'
|
||||||
|
execute_single_checker(registrant_user_code)
|
||||||
|
else
|
||||||
|
raise "Invalid type: #{type}. Allowed types: 'bulk', 'single'"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def execute_bulk_checker(spam_delay)
|
||||||
|
log("Bulk checker started")
|
||||||
|
|
||||||
|
Contact.where(ident_type: 'org', ident_country_code: 'EE').joins(:registrant_domains).each do |registrant_user|
|
||||||
|
is_phone_number_matching = check_the_registrant_phone_number(registrant_user)
|
||||||
|
|
||||||
|
call_disclosure_action(is_phone_number_matching, registrant_user)
|
||||||
|
sleep(spam_delay)
|
||||||
|
end
|
||||||
|
|
||||||
|
log("Bulk checker finished")
|
||||||
|
end
|
||||||
|
|
||||||
|
def execute_single_checker(registrant_user_code)
|
||||||
|
registrant_user = RegistrantUser.find_by(code: registrant_user_code)
|
||||||
|
is_phone_number_matching = check_the_registrant_phone_number(registrant_user)
|
||||||
|
|
||||||
|
call_disclosure_action(is_phone_number_matching, registrant_user)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def call_disclosure_action(is_phone_number_matching, contact)
|
||||||
|
if is_phone_number_matching
|
||||||
|
disclose_phone_number(contact)
|
||||||
|
log("Phone number disclosed for registrant user #{contact.code}. Phone number: #{contact.phone}")
|
||||||
|
elsif contact.disclosed_attributes.include?('phone')
|
||||||
|
log("Removing phone number from disclosed attributes for registrant user #{contact.code}. Phone number: #{contact.phone}")
|
||||||
|
contact.disclosed_attributes.delete('phone')
|
||||||
|
contact.save!
|
||||||
|
else
|
||||||
|
log("Phone number not disclosed for registrant user #{contact.code}. Phone number: #{contact.phone}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def log(message)
|
||||||
|
Rails.logger.info(message)
|
||||||
|
end
|
||||||
|
|
||||||
|
def disclose_phone_number(contact)
|
||||||
|
contact.disclosed_attributes << 'phone'
|
||||||
|
contact.save!
|
||||||
|
end
|
||||||
|
|
||||||
|
def company_register
|
||||||
|
@company_register ||= CompanyRegister::Client.new
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_the_registrant_phone_number(registrant_user)
|
||||||
|
phone_numbers = fetch_phone_number_from_company_register(registrant_user.ident)
|
||||||
|
|
||||||
|
# TODO: implement phone number check
|
||||||
|
# If phone number is matching with registrant phone number, then return return true, else return false
|
||||||
|
|
||||||
|
phone_numbers.any? do |phone_number|
|
||||||
|
puts '---- business registry phone number ----'
|
||||||
|
puts phone_number
|
||||||
|
puts '---- registrant phone number ----'
|
||||||
|
puts registrant_user.phone
|
||||||
|
puts '---- format phone number ----'
|
||||||
|
puts format_phone_number(phone_number)
|
||||||
|
puts '---- format registrant phone number ----'
|
||||||
|
puts format_phone_number(registrant_user.phone)
|
||||||
|
|
||||||
|
format_phone_number(phone_number) == format_phone_number(registrant_user.phone)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def format_phone_number(phone_number)
|
||||||
|
# phone number from business registry is "+3725655662"
|
||||||
|
# we need to format it to "+3725655662"
|
||||||
|
phone_number.gsub(/\D/, '')
|
||||||
|
end
|
||||||
|
|
||||||
|
def fetch_phone_number_from_company_register(company_code)
|
||||||
|
data = company_register.company_details(registration_number: company_code.to_s)
|
||||||
|
data[0].phone_numbers
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue