diff --git a/app/presenters/image_upload_response_presenter.rb b/app/presenters/image_upload_response_presenter.rb index 6395f2ea889..e6476312323 100644 --- a/app/presenters/image_upload_response_presenter.rb +++ b/app/presenters/image_upload_response_presenter.rb @@ -51,8 +51,9 @@ def as_json(*) json[:ocr_pii] = ocr_pii json[:result_failed] = doc_auth_result_failed? json[:doc_type_supported] = doc_type_supported? - json[:selfie_live] = selfie_live? if show_selfie_failures - json[:selfie_quality_good] = selfie_quality_good? if show_selfie_failures + json[:selfie_status] = selfie_status if show_selfie_failures? + json[:selfie_live] = selfie_live? if show_selfie_failures? + json[:selfie_quality_good] = selfie_quality_good? if show_selfie_failures? json[:failed_image_fingerprints] = failed_fingerprints json end @@ -90,10 +91,14 @@ def failed_fingerprints @form_response.extra[:failed_image_fingerprints] || { front: [], back: [], selfie: [] } end - def show_selfie_failures + def show_selfie_failures? @form_response.extra[:liveness_checking_required] == true end + def selfie_status + @form_response.respond_to?(:selfie_status) ? @form_response.selfie_status : :not_processed + end + def selfie_live? @form_response.respond_to?(:selfie_live?) ? @form_response.selfie_live? : true end diff --git a/app/services/doc_auth/mock/result_response.rb b/app/services/doc_auth/mock/result_response.rb index 2a6c12a6805..52bd4699761 100644 --- a/app/services/doc_auth/mock/result_response.rb +++ b/app/services/doc_auth/mock/result_response.rb @@ -23,6 +23,7 @@ def initialize(uploaded_file, config, selfie_required = false) portrait_match_results: portrait_match_results, billed: true, classification_info: classification_info, + liveness_checking_required: @selfie_required, }.compact, ) end @@ -245,6 +246,7 @@ def create_response_info( liveness_enabled: liveness_enabled, classification_info: classification_info, portrait_match_results: selfie_check_performed? ? portrait_match_results : nil, + extra: { liveness_checking_required: liveness_enabled }, }.compact end end diff --git a/app/services/doc_auth/response.rb b/app/services/doc_auth/response.rb index 5c311934a82..994f0b3b229 100644 --- a/app/services/doc_auth/response.rb +++ b/app/services/doc_auth/response.rb @@ -18,6 +18,7 @@ def initialize( pii_from_doc: {}, attention_with_barcode: false, doc_type_supported: true, + selfie_status: :not_processed, selfie_live: true, selfie_quality_good: true ) @@ -28,6 +29,7 @@ def initialize( @pii_from_doc = pii_from_doc @attention_with_barcode = attention_with_barcode @doc_type_supported = doc_type_supported + @selfie_status = selfie_status @selfie_live = selfie_live @selfie_quality_good = selfie_quality_good end @@ -41,6 +43,7 @@ def merge(other) pii_from_doc: pii_from_doc.merge(other.pii_from_doc), attention_with_barcode: attention_with_barcode? || other.attention_with_barcode?, doc_type_supported: doc_type_supported? || other.doc_type_supported?, + selfie_status: selfie_status, selfie_live: selfie_live?, selfie_quality_good: selfie_quality_good?, ) diff --git a/spec/services/doc_auth/mock/result_response_spec.rb b/spec/services/doc_auth/mock/result_response_spec.rb index 227b3c6284a..15ca9496f72 100644 --- a/spec/services/doc_auth/mock/result_response_spec.rb +++ b/spec/services/doc_auth/mock/result_response_spec.rb @@ -303,6 +303,7 @@ doc_auth_result: DocAuth::Acuant::ResultCodes::PASSED.name, billed: true, classification_info: {}, + liveness_checking_required: false, ) expect(response.doc_auth_success?).to eq(true) expect(response.selfie_status).to eq(:not_processed) @@ -332,6 +333,7 @@ doc_auth_result: DocAuth::Acuant::ResultCodes::CAUTION.name, billed: true, classification_info: {}, + liveness_checking_required: false, ) end end @@ -357,6 +359,7 @@ doc_auth_result: DocAuth::Acuant::ResultCodes::FAILED.name, billed: true, classification_info: {}, + liveness_checking_required: false, ) end end @@ -403,6 +406,7 @@ doc_auth_result: DocAuth::Acuant::ResultCodes::PASSED.name, billed: true, classification_info: {}, + liveness_checking_required: false, ) end end @@ -700,6 +704,7 @@ expect(response.extra[:portrait_match_results]).to eq(selfie_results) expect(response.doc_auth_success?).to eq(true) expect(response.selfie_status).to eq(:fail) + expect(response.extra[:liveness_checking_required]).to eq(true) end end end @@ -713,6 +718,7 @@ expect(response.extra).not_to have_key(:portrait_match_results) expect(response.doc_auth_success?).to eq(true) expect(response.selfie_status).to eq(:not_processed) + expect(response.extra[:liveness_checking_required]).to eq(false) end end end