Log deleted contacts to file, don't send poll message on initial cycle

This commit is contained in:
Karl Erik Õunapuu 2020-09-16 11:13:50 +03:00
parent ab1fa9064e
commit 7e9a3250bd
No known key found for this signature in database
GPG key ID: C9DD647298A34764
3 changed files with 17 additions and 4 deletions

View file

@ -17,12 +17,13 @@ module Concerns
inactive
end
def archive(verified: false, notify: true)
def archive(verified: false, notify: true, extra_log: false)
unless verified
raise 'Contact cannot be archived' unless archivable?(post: true)
end
notify_registrar_about_archivation if notify
write_to_registrar_log if extra_log
destroy!
end
@ -51,6 +52,17 @@ module Concerns
@log ||= Logger.new(STDOUT)
@log.info(msg)
end
def write_to_registrar_log
registrar_name = registrar.accounting_customer_code
archive_path = ENV['contact_archivation_log_file_dir']
registrar_log_path = "#{archive_path}/#{registrar_name}.txt"
FileUtils.mkdir_p(archive_path) unless Dir.exist?(archive_path)
f = File.new(registrar_log_path, 'a+')
f.write("#{code}\n")
f.close
end
end
end
end