Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
d63b835
Update providers/contacts to allow for consistency in the data, and a…
svogt0511 Jun 7, 2026
f5cbbf6
Appease rubocop.
svogt0511 Jun 7, 2026
0ec150d
Force save of contacts and provider
svogt0511 Jun 8, 2026
256df51
Debug
svogt0511 Jun 8, 2026
8a406d3
Appease rubocop.
svogt0511 Jun 8, 2026
f80b8b0
Debugging.
svogt0511 Jun 8, 2026
c992640
Debug
svogt0511 Jun 8, 2026
aeb49ee
Debug
svogt0511 Jun 8, 2026
9662900
Debugging
svogt0511 Jun 8, 2026
5df98d0
debugging
svogt0511 Jun 9, 2026
6f87b39
Mods to contacts role handling.
svogt0511 Jun 9, 2026
6462385
debugging
svogt0511 Jun 9, 2026
2203a56
Appease rubocop.
svogt0511 Jun 9, 2026
e9d371b
debugging
svogt0511 Jun 9, 2026
e6be347
Mods to contacts controller - set_provider_contacts.
svogt0511 Jun 11, 2026
e1ea92f
Mods to contacts controller - set_provider_contacts.
svogt0511 Jun 11, 2026
dc2b10e
Make sure @contact is sent to salesforce in contacts controller.
svogt0511 Jun 12, 2026
46218ae
Make sure new new/contact is pushed to salesforce.
svogt0511 Jun 12, 2026
bacffbc
Clean up and hope it still works.
svogt0511 Jun 12, 2026
96e279c
Clean up.
svogt0511 Jun 12, 2026
f0e63b3
Mods to providers controller - set_provider_contacts
svogt0511 Jun 14, 2026
cf2a182
Newly discovered net-imap security issue, update from 6.4.0 to 6.4.1
svogt0511 Jun 14, 2026
3581423
Temporarily remove after_action, remove_provider_contacts.
svogt0511 Jun 14, 2026
61dcbd7
Cleanup and verify that deleting a contact works to remove it and its…
svogt0511 Jun 14, 2026
83c7f4f
Clean up indexable.rb
svogt0511 Jun 14, 2026
e83b323
Appease rubocop
svogt0511 Jun 14, 2026
45cbd1b
Remove after_action :remove_provider_contacts on provider delete. We…
svogt0511 Jun 14, 2026
de438fb
Fix errors.
svogt0511 Jun 15, 2026
3c52004
Appease rubocop.
svogt0511 Jun 15, 2026
d446f80
Fix the double render error by moving the method to the controller in…
svogt0511 Jun 16, 2026
b42bab9
Merge remote-tracking branch 'origin/master' into pb2207-salesforce-c…
svogt0511 Jun 16, 2026
1fbd595
Update integrate updated contact control into the create and update m…
svogt0511 Jun 16, 2026
7136a11
Make sure contacts are saved.
svogt0511 Jun 16, 2026
09f649e
Fix error.
svogt0511 Jun 16, 2026
c407d0a
Fix bug with provider contacts being forwarded to salesforce.
svogt0511 Jun 17, 2026
246519c
Appease rubocop.
svogt0511 Jun 17, 2026
04d5499
Provider - check out salesforce messages.
svogt0511 Jun 17, 2026
3f8d92d
Fix bug with provider contacts being forwarded to salesforce
svogt0511 Jun 18, 2026
1dbd7b5
Update.
svogt0511 Jun 18, 2026
8fe8657
Update.
svogt0511 Jun 18, 2026
e6044a4
update
svogt0511 Jun 18, 2026
cf69a27
Update excon to 1.5.0 - to handle latest security issue.
svogt0511 Jun 18, 2026
3a900f5
update
svogt0511 Jun 18, 2026
335a5f7
update
svogt0511 Jun 18, 2026
ed8337c
update
svogt0511 Jun 19, 2026
02bdb00
update
svogt0511 Jun 19, 2026
9dfca58
update
svogt0511 Jun 19, 2026
a620ff8
update
svogt0511 Jun 19, 2026
c8e3359
update - make sure @contact updates are actually sent to salesforce.
svogt0511 Jun 19, 2026
72b4c73
update
svogt0511 Jun 19, 2026
0fcba1a
update
svogt0511 Jun 19, 2026
f0c9b79
update
svogt0511 Jun 20, 2026
c761647
update
svogt0511 Jun 20, 2026
bec6a83
update
svogt0511 Jun 20, 2026
7665538
update
svogt0511 Jun 21, 2026
83d4ad2
Update nokogiri per security notice
svogt0511 Jun 21, 2026
b2514fc
update
svogt0511 Jun 21, 2026
a279263
update
svogt0511 Jun 21, 2026
48bc02a
update
svogt0511 Jun 21, 2026
57fd21c
Merge remote-tracking branch 'origin/master' into pb2207-salesforce-c…
svogt0511 Jun 22, 2026
a441b14
Looking for soluton to inconsistent salesforce updates for contacts a…
svogt0511 Jun 22, 2026
423bdb6
update faraday per security notice
svogt0511 Jun 22, 2026
56293ab
Merge remote-tracking branch 'origin/master' into pb2207-salesforce-c…
svogt0511 Jun 22, 2026
db60164
update
svogt0511 Jun 22, 2026
884e331
update
svogt0511 Jun 22, 2026
3aa6f68
update
svogt0511 Jun 22, 2026
8e51ec0
update
svogt0511 Jun 22, 2026
f186775
update
svogt0511 Jun 22, 2026
a9125d0
update
svogt0511 Jun 22, 2026
5f4afa6
update
svogt0511 Jun 22, 2026
e22b480
Update oj and concurrent-ruby gems per the security advisories.
svogt0511 Jun 23, 2026
3d52e23
Merge remote-tracking branch 'origin/master' into pb2207-salesforce-c…
svogt0511 Jun 23, 2026
f5d0112
updates
svogt0511 Jun 23, 2026
5abbc2b
update
svogt0511 Jun 23, 2026
d3d7f9f
update
svogt0511 Jun 23, 2026
72e47c1
update - 1
svogt0511 Jun 24, 2026
15cbd40
updates 2
svogt0511 Jun 24, 2026
48e99c5
update
svogt0511 Jun 24, 2026
f0ee77d
update
svogt0511 Jun 24, 2026
efceb37
update
svogt0511 Jun 24, 2026
0d835ea
appease rubocop
svogt0511 Jun 24, 2026
63e02f8
update
svogt0511 Jun 24, 2026
660648d
update
svogt0511 Jun 25, 2026
0e90ba8
update
svogt0511 Jun 25, 2026
ee79e24
update
svogt0511 Jun 25, 2026
86617a9
update
svogt0511 Jun 26, 2026
0aff9f4
update
svogt0511 Jun 26, 2026
14d728a
update
svogt0511 Jun 26, 2026
468a8e5
Update providers_controller.
svogt0511 Jun 26, 2026
ef10c82
Merge remote-tracking branch 'origin/master' into pb2207-salesforce-c…
svogt0511 Jun 26, 2026
ecb80dd
Update providers_controller.
svogt0511 Jun 28, 2026
e2bc37f
Update crass gem (indirect dependency) to 1.0.7
svogt0511 Jun 28, 2026
428cdc7
Update providers_controlle - on create, export provider first to sale…
svogt0511 Jun 29, 2026
d0901df
Uncomment provider export.
svogt0511 Jun 29, 2026
f6dbf9a
Update providers_controller, exporting contacts first on create, then…
svogt0511 Jun 29, 2026
56983f3
Update providers_controller - update contacts on create.
svogt0511 Jun 29, 2026
60801b5
update
svogt0511 Jun 29, 2026
ad7a059
appease rubocop
svogt0511 Jun 29, 2026
f975920
Update providers before contacts (esp on create)
svogt0511 Jun 29, 2026
aaa1b33
Update contacts controller.
svogt0511 Jun 29, 2026
80f2bc1
Appease rubocop
svogt0511 Jun 29, 2026
5de0ea1
Update msgpack per security notice.
svogt0511 Jun 29, 2026
ff933fc
Update css_parser per security notice.
svogt0511 Jun 29, 2026
24e864d
Add export.
svogt0511 Jun 29, 2026
d7237c6
Set role_name to [] on contact create, if it is nil.
svogt0511 Jul 1, 2026
89c97ce
Set role_name to [] on contact create, if it is nil.
svogt0511 Jul 1, 2026
950627d
Clean up.
svogt0511 Jul 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ GEM
crack (1.0.1)
bigdecimal
rexml
crass (1.0.6)
crass (1.0.7)
crawler_detect (1.2.11)
qonfig (>= 0.24)
csl (2.2.1)
Expand All @@ -196,8 +196,9 @@ GEM
time (< 1.0)
csl-styles (2.0.2)
csl (~> 2.0)
css_parser (2.2.0)
css_parser (3.0.0)
addressable
ssrf_filter (~> 1.5)
csv (3.3.5)
dalli (5.0.2)
logger
Expand Down Expand Up @@ -476,7 +477,7 @@ GEM
minitest (6.0.6)
drb (~> 2.0)
prism (~> 1.5)
msgpack (1.8.0)
msgpack (1.8.3)
multi_json (1.21.1)
multipart-post (2.4.1)
mysql2 (0.5.7)
Expand Down Expand Up @@ -729,6 +730,7 @@ GEM
sparql-client (3.3.0)
net-http-persistent (~> 4.0, >= 4.0.2)
rdf (~> 3.3)
ssrf_filter (1.5.0)
string_pattern (2.4.0)
regexp_parser (~> 2.5, >= 2.5.0)
stringio (3.2.0)
Expand Down Expand Up @@ -864,4 +866,4 @@ DEPENDENCIES
webmock (~> 3.26, >= 3.26.2)

BUNDLED WITH
2.6.9
4.0.14
67 changes: 51 additions & 16 deletions app/controllers/contacts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ class ContactsController < ApplicationController
before_action :authenticate_user!
before_action :set_include

after_action :set_provider_contacts, only: %i[create update]
after_action :remove_provider_contacts, only: %i[destroy]
load_and_authorize_resource

def index
Expand Down Expand Up @@ -122,12 +120,16 @@ def create
@contact = Contact.new(safe_params)
authorize! :create, @contact

@contact.role_name = [] if @contact.role_name.nil?

if @contact.save
options = {}
options[:include] = @include
options[:is_collection] = false
options[:params] = { current_ability: current_ability, detail: true }

set_provider_contacts

render(
json: ContactSerializer.new(@contact, options).serializable_hash.to_json,
status: :created
Expand All @@ -140,12 +142,17 @@ def create
end

def update
if @contact.update(safe_params)
@contact.assign_attributes(safe_params)
@contact.role_name = [] if @contact.role_name.nil?

if @contact.save
options = {}
options[:include] = @include
options[:is_collection] = false
options[:params] = { current_ability: current_ability, detail: true }

set_provider_contacts

render(
json: ContactSerializer.new(@contact, options).serializable_hash.to_json,
status: :ok
Expand All @@ -160,6 +167,7 @@ def update
# don't delete, but set deleted_at timestamp
def destroy
if @contact.update(deleted_at: Time.zone.now)
remove_provider_contacts
head :no_content
else
# Rails.logger.error @contact.errors.inspect
Expand Down Expand Up @@ -191,33 +199,60 @@ def set_include

private
def set_provider_contacts
if @contact.valid?
Contact.roles.each do | role |
if @contact.has_role?(role)
@contact.set_provider_role(role, { 'email': @contact.email, 'given_name': @contact.given_name, 'family_name': @contact.family_name })
elsif @contact.has_provider_role?(role)
@contact.set_provider_role(role, nil)
end
end
if @contact.valid? && @contact.provider.present?
contacts = @contact.provider.contacts.where(deleted_at: nil)
provider = @contact.provider

# Make sure no other contact with this provider claims these roles.
@contact.provider.contacts.each do | contact |
contacts.each do | contact |
if !@contact.is_me?(contact)
if contact.remove_roles!(Array.wrap(@contact.role_name))
contact.update_attribute("role_name", contact.role_name)
old_role_name = contact.role_name.present? ? contact.role_name : []
new_role_name = (contact.role_name.present? ? contact.role_name : []) - (@contact.role_name.present? ? @contact.role_name : [])
if old_role_name.sort != new_role_name.sort
contact.update_column("role_name", new_role_name)
end
end
end

# Clear provider role associations.
Contact.roles.each do | role |
@contact.set_provider_role!(role, nil)
end

# Reset provider role associations.
contacts.each do |contact|
contact&.role_name&.each do | role |
if contact.has_role?(role)
contact.set_provider_role!(role, { 'email': contact.email || nil, 'given_name': contact.given_name || nil, 'family_name': contact.family_name || nil })
end
end
end

# Send provider export message. (Ignore if record was created/updated via Salesforce API)
provider.save
provider.send_provider_export_message(provider.to_jsonapi.merge(slack_output: true)) if !provider.from_salesforce && (Rails.env.production? || ENV["SQS_PREFIX"] == "stage")

# Send contact export messages. (Ignore if record was created/updated via Salesforce API)
contacts.each do |contact|
contact.save
contact.send_contact_export_message(contact.to_jsonapi.merge(slack_output: true)) if !contact.from_salesforce && (Rails.env.production? || ENV["SQS_PREFIX"] == "stage")
end
end
end

def remove_provider_contacts
Array.wrap(@contact.role_name).each do | role |
if @contact.has_provider_role?(role)
@contact.set_provider_role(role, nil)
@contact.set_provider_role!(role, nil)
end
end
@contact.update_attribute("role_name", [])
@contact.role_name = []

@contact.provider.save
@contact.provider.send_provider_export_message(@contact.provider.to_jsonapi.merge(slack_output: true)) if !@contact.provider.from_salesforce && (Rails.env.production? || ENV["SQS_PREFIX"] == "stage")

@contact.save
@contact.send_contact_export_message(@contact.to_jsonapi.merge(slack_output: true)) if !@contact.from_salesforce && (Rails.env.production? || ENV["SQS_PREFIX"] == "stage")
end

def safe_params
Expand Down
55 changes: 55 additions & 0 deletions app/controllers/providers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ def create
options[:is_collection] = false
options[:params] = { current_ability: current_ability, detail: true }

set_provider_contacts

render(
json: ProviderSerializer.new(@provider, options).serializable_hash.to_json,
status: :ok
Expand All @@ -219,6 +221,8 @@ def update
options[:is_collection] = false
options[:params] = { current_ability: current_ability, detail: true }

set_provider_contacts

render(
json: ProviderSerializer.new(@provider, options).serializable_hash.to_json,
status: :ok
Expand Down Expand Up @@ -336,6 +340,57 @@ def set_provider
end

private
def set_provider_contacts
if @provider.valid?
contacts = @provider.contacts.where(deleted_at: nil).to_a

# Clear contact role associations for this provider.
contacts.each { |contact|
contact.role_name = []
}

# Reset contact role associations to the new ones for this provider.
Contact.roles.each do | target_role |
target_role_name = target_role + "_contact"
contact_data = @provider.send(target_role_name)

if contact_data.present? && contact_data["email"].present?
target_email = contact_data["email"]
target_given_name = contact_data["given_name"] || nil
target_family_name = contact_data["family_name"] || nil

# Find matching contact; if none exists, build it and add it to our set of contacts for this provider.
contact = contacts.find { |c| c.email.downcase == target_email.downcase }

if contact.nil?
contact = @provider.contacts.build(email: target_email)
contact.role_name = []
contacts << contact
end

contact.role_name |= [ target_role ]
contact.given_name = target_given_name
contact.family_name = target_family_name
end
end

# Send provider export message. (Ignore if record was created/updated via Salesforce API)
@provider.save
@provider.send_provider_export_message(@provider.to_jsonapi.merge(slack_output: true)) if !@provider.from_salesforce && (Rails.env.production? || ENV["SQS_PREFIX"] == "stage")

# We might have added contacts to what was originally an empty set.
if contacts.empty?
contacts = @provider.contacts.where(deleted_at: nil).to_a
end

# Send contact export messages. (Ignore if record was created/updated via Salesforce API)
contacts.each do |contact|
contact.save
contact.send_contact_export_message(contact.to_jsonapi.merge(slack_output: true)) if !contact.from_salesforce && (Rails.env.production? || ENV["SQS_PREFIX"] == "stage")
end
end
end

def safe_params
if params[:data].blank?
fail JSON::ParserError,
Expand Down
4 changes: 0 additions & 4 deletions app/models/concerns/indexable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,8 @@ module Indexable
end
end
# ignore if record was created via Salesforce API
elsif instance_of?(Provider) && !from_salesforce && (Rails.env.production? || ENV["SQS_PREFIX"] == "stage")
send_provider_export_message(to_jsonapi.merge(slack_output: true))
elsif instance_of?(Client) && !from_salesforce && (Rails.env.production? || ENV["SQS_PREFIX"] == "stage")
send_client_export_message(to_jsonapi.merge(slack_output: true))
elsif instance_of?(Contact) && !from_salesforce && (Rails.env.production? || ENV["SQS_PREFIX"] == "stage")
send_contact_export_message(to_jsonapi.merge(slack_output: true))
end
end

Expand Down
25 changes: 17 additions & 8 deletions app/models/contact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,14 @@ def remove_roles!(roles = [])
self.changed?
end

def remove_roles(roles = [])
role_name = Array.wrap(self.role_name)
roles.each do | role |
role_name.delete(role)
end
role_name
end

def is_me?(contact = nil)
uid == contact.uid
end
Expand All @@ -482,22 +490,23 @@ def has_provider_role?(role)
end
end

def set_provider_role(role, contact)
def set_provider_role!(role, contact = nil)
# puts "**setting provider role #{role} contact to #{contact.email} for provider #{provider.symbol}"
case role
when "voting"
provider.update_attribute("voting_contact", contact)
provider.voting_contact = contact
when "billing"
provider.update_attribute("billing_contact", contact)
provider.billing_contact = contact
when "secondary_billing"
provider.update_attribute("secondary_billing_contact", contact)
provider.secondary_billing_contact = contact
when "service"
provider.update_attribute("service_contact", contact)
provider.service_contact = contact
when "secondary_service"
provider.update_attribute("secondary_service_contact", contact)
provider.secondary_service_contact = contact
when "technical"
provider.update_attribute("technical_contact", contact)
provider.technical_contact = contact
when "secondary_technical"
provider.update_attribute("secondary_technical_contact", contact)
provider.secondary_technical_contact = contact
end
end

Expand Down
1 change: 1 addition & 0 deletions app/models/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ class Provider < ApplicationRecord
before_save { self.updated = Time.zone.now.utc.iso8601 }

accepts_nested_attributes_for :prefixes
accepts_nested_attributes_for :contacts

# use different index for testing
if Rails.env.test?
Expand Down
Loading