From c256a1290a32256651c645909a3f8852cd6c76ac Mon Sep 17 00:00:00 2001 From: oleghasjanov Date: Fri, 27 Jun 2025 12:27:59 +0300 Subject: [PATCH 1/2] feat: Add system disclosed attributes for contact phone numbers - Add system_disclosed_attributes array column to contacts table - Update OrgRegistrantPhoneCheckerJob to manage both user and system disclosed attributes - Include system_disclosed_attributes in contact API serializer This change introduces a new way to track system-level disclosure of contact attributes, separate from user-defined disclosures. When a phone number matches the company register data, it will be marked as disclosed both in user and system attributes. This allows better tracking of which attributes were automatically disclosed by the system versus manually disclosed by users. --- app/jobs/org_registrant_phone_checker_job.rb | 4 +++- ...0627084536_add_system_disclosed_attributes_to_contact.rb | 5 +++++ db/structure.sql | 6 ++++-- lib/serializers/registrant_api/contact.rb | 1 + 4 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20250627084536_add_system_disclosed_attributes_to_contact.rb diff --git a/app/jobs/org_registrant_phone_checker_job.rb b/app/jobs/org_registrant_phone_checker_job.rb index 1d791acac5..4dcb837a65 100644 --- a/app/jobs/org_registrant_phone_checker_job.rb +++ b/app/jobs/org_registrant_phone_checker_job.rb @@ -54,9 +54,10 @@ 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') + elsif contact.disclosed_attributes.include?('phone') || contact.system_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.system_disclosed_attributes.delete('phone') contact.save! else log("Phone number not disclosed for registrant user #{contact.code}. Phone number: #{contact.phone}") @@ -69,6 +70,7 @@ def log(message) def disclose_phone_number(contact) contact.disclosed_attributes << 'phone' + contact.system_disclosed_attributes << 'phone' contact.save! end diff --git a/db/migrate/20250627084536_add_system_disclosed_attributes_to_contact.rb b/db/migrate/20250627084536_add_system_disclosed_attributes_to_contact.rb new file mode 100644 index 0000000000..f77b5a7244 --- /dev/null +++ b/db/migrate/20250627084536_add_system_disclosed_attributes_to_contact.rb @@ -0,0 +1,5 @@ +class AddSystemDisclosedAttributesToContact < ActiveRecord::Migration[6.1] + def change + add_column :contacts, :system_disclosed_attributes, :string, array: true, default: [] + end +end diff --git a/db/structure.sql b/db/structure.sql index 02f8f6d61b..eb4a715bae 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -697,7 +697,8 @@ CREATE TABLE public.contacts ( company_register_status character varying, ident_request_sent_at timestamp without time zone, verified_at timestamp without time zone, - verification_id character varying + verification_id character varying, + system_disclosed_attributes character varying[] DEFAULT '{}'::character varying[] ); @@ -5728,6 +5729,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20250204094550'), ('20250219102811'), ('20250313122119'), -('20250319104749'); +('20250319104749'), +('20250627084536'); diff --git a/lib/serializers/registrant_api/contact.rb b/lib/serializers/registrant_api/contact.rb index 6f3aa03b98..d28a2c96e7 100644 --- a/lib/serializers/registrant_api/contact.rb +++ b/lib/serializers/registrant_api/contact.rb @@ -31,6 +31,7 @@ def to_json(_obj = nil) auth_info: contact.auth_info, statuses: contact.statuses, disclosed_attributes: contact.disclosed_attributes, + system_disclosed_attributes: contact.system_disclosed_attributes, registrant_publishable: contact.registrant_publishable, } From 8f5a90cdfc90c25fc681b108d3c1861ab64cf3b5 Mon Sep 17 00:00:00 2001 From: oleghasjanov Date: Fri, 27 Jun 2025 13:35:05 +0300 Subject: [PATCH 2/2] fixed test --- test/integration/api/v1/registrant/contacts/details_test.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/integration/api/v1/registrant/contacts/details_test.rb b/test/integration/api/v1/registrant/contacts/details_test.rb index 66aecb28a0..08b4196218 100644 --- a/test/integration/api/v1/registrant/contacts/details_test.rb +++ b/test/integration/api/v1/registrant/contacts/details_test.rb @@ -39,7 +39,8 @@ def test_returns_contact_details auth_info: @contact.auth_info, statuses: @contact.statuses, disclosed_attributes: @contact.disclosed_attributes, - registrant_publishable: @contact.registrant_publishable }), + registrant_publishable: @contact.registrant_publishable, + system_disclosed_attributes: @contact.system_disclosed_attributes }), JSON.parse(response.body, symbolize_names: true) end