Class: SupportingEvidenceAttachment
- Inherits:
-
FormAttachment
- Object
- ActiveRecord::Base
- ApplicationRecord
- FormAttachment
- SupportingEvidenceAttachment
- Defined in:
- app/models/supporting_evidence_attachment.rb
Overview
Files uploaded as part of a form526 submission that will be sent to EVSS upon form submission. inherits from ApplicationRecord
Constant Summary collapse
- ATTACHMENT_UPLOADER_CLASS =
SupportingEvidenceAttachmentUploader
- FILENAME_EXTENSION_MATCHER =
/\.\w*$/
- OBFUSCATED_CHARACTER_MATCHER =
/[a-zA-Z\d]/
Instance Method Summary collapse
- #converted_filename ⇒ Object
-
#obscured_filename ⇒ Object
Obfuscates the attachment’s file name for use in mailers, so we don’t email PII The intent is the file should still be recognizable to the veteran who uploaded it Follows these rules: - Only masks filenames longer than 5 characters - Masks letters and numbers, but preserves special characters - Includes the file extension.
- #original_filename ⇒ Object
-
#set_file_data!(file, file_password = nil) ⇒ Object
this uploads the file to S3 through its parent class the final filename comes from the uploader once the file is successfully uploaded to S3.
Methods inherited from FormAttachment
#get_attachment_uploader, #get_file, #parsed_file_data, #unlock_pdf
Methods included from SentryLogging
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata
Methods inherited from ApplicationRecord
descendants_using_encryption, lockbox_options, #timestamp_attributes_for_update_in_model, #valid?
Instance Method Details
#converted_filename ⇒ Object
21 22 23 |
# File 'app/models/supporting_evidence_attachment.rb', line 21 def converted_filename parsed_file_data['converted_filename'] end |
#obscured_filename ⇒ Object
Obfuscates the attachment’s file name for use in mailers, so we don’t email PII The intent is the file should still be recognizable to the veteran who uploaded it Follows these rules:
-
Only masks filenames longer than 5 characters
-
Masks letters and numbers, but preserves special characters
-
Includes the file extension
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/models/supporting_evidence_attachment.rb', line 35 def obscured_filename extension = original_filename[FILENAME_EXTENSION_MATCHER] filename_without_extension = original_filename.gsub(FILENAME_EXTENSION_MATCHER, '') if filename_without_extension.length > 5 # Obfuscate with the letter 'X'; we cannot obfuscate with special characters such as an asterisk, # as these filenames appear in VA Notify Mailers and their templating engine uses markdown. # Therefore, special characters can be interpreted as markdown and introduce formatting issues in the mailer = filename_without_extension[3..-3].gsub(OBFUSCATED_CHARACTER_MATCHER, 'X') filename_without_extension[0..2] + + filename_without_extension[-2..] + extension else original_filename end end |
#original_filename ⇒ Object
25 26 27 |
# File 'app/models/supporting_evidence_attachment.rb', line 25 def original_filename parsed_file_data['filename'] end |
#set_file_data!(file, file_password = nil) ⇒ Object
this uploads the file to S3 through its parent class the final filename comes from the uploader once the file is successfully uploaded to S3
12 13 14 15 16 17 18 19 |
# File 'app/models/supporting_evidence_attachment.rb', line 12 def set_file_data!(file, file_password = nil) file_data_json = super au = if au.converted_exists? self.file_data = JSON.parse(file_data_json).merge('converted_filename' => au.final_filename).to_json end file_data end |