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.
This commit is contained in:
oleghasjanov 2025-06-27 12:27:59 +03:00
parent 2bc5f50474
commit c256a1290a
4 changed files with 13 additions and 3 deletions

View file

@ -54,9 +54,10 @@ class OrgRegistrantPhoneCheckerJob < ApplicationJob
if is_phone_number_matching if is_phone_number_matching
disclose_phone_number(contact) disclose_phone_number(contact)
log("Phone number disclosed for registrant user #{contact.code}. Phone number: #{contact.phone}") 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}") log("Removing phone number from disclosed attributes for registrant user #{contact.code}. Phone number: #{contact.phone}")
contact.disclosed_attributes.delete('phone') contact.disclosed_attributes.delete('phone')
contact.system_disclosed_attributes.delete('phone')
contact.save! contact.save!
else else
log("Phone number not disclosed for registrant user #{contact.code}. Phone number: #{contact.phone}") log("Phone number not disclosed for registrant user #{contact.code}. Phone number: #{contact.phone}")
@ -69,6 +70,7 @@ class OrgRegistrantPhoneCheckerJob < ApplicationJob
def disclose_phone_number(contact) def disclose_phone_number(contact)
contact.disclosed_attributes << 'phone' contact.disclosed_attributes << 'phone'
contact.system_disclosed_attributes << 'phone'
contact.save! contact.save!
end end

View file

@ -0,0 +1,5 @@
class AddSystemDisclosedAttributesToContact < ActiveRecord::Migration[6.1]
def change
add_column :contacts, :system_disclosed_attributes, :string, array: true, default: []
end
end

View file

@ -697,7 +697,8 @@ CREATE TABLE public.contacts (
company_register_status character varying, company_register_status character varying,
ident_request_sent_at timestamp without time zone, ident_request_sent_at timestamp without time zone,
verified_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'), ('20250204094550'),
('20250219102811'), ('20250219102811'),
('20250313122119'), ('20250313122119'),
('20250319104749'); ('20250319104749'),
('20250627084536');

View file

@ -31,6 +31,7 @@ module Serializers
auth_info: contact.auth_info, auth_info: contact.auth_info,
statuses: contact.statuses, statuses: contact.statuses,
disclosed_attributes: contact.disclosed_attributes, disclosed_attributes: contact.disclosed_attributes,
system_disclosed_attributes: contact.system_disclosed_attributes,
registrant_publishable: contact.registrant_publishable, registrant_publishable: contact.registrant_publishable,
} }