This repository has been archived by the owner on Mar 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
URL parameter targets for call tool (#991)
* backend changes to allow calls to target passed in params, w spec * pass relevant url params in to call tool js * remove misuse of country_code call_tool parameter * Abstraction for exposing data hash for call tool plugin * Use ExposedData helper. * finish out back-end for passing targets through params * update yarn snapshots * close the loop, get the front-end to handle prefilled targets * deploy call-preselect to staging * fix flow errors * add missing config for call targeting
- Loading branch information
Showing
18 changed files
with
338 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module CallTool | ||
class ChecksumValidator | ||
def self.validate(phone_number, checksum) | ||
return false if phone_number.blank? || checksum.blank? | ||
unhashed = "#{phone_number}#{Settings.calls.targeting_secret}" | ||
checksum == Digest::SHA256.hexdigest(unhashed)[0..5] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module CallTool | ||
class ExposedData | ||
attr_reader :query | ||
RELEVANT_ATTRIBUTES = %i[target_name target_title target_phone_number target_phone_extension checksum].freeze | ||
|
||
def initialize(plugin_data, query) | ||
@query = query | ||
@plugin_data = plugin_data | ||
end | ||
|
||
def to_h | ||
return @plugin_data unless encoded_target_valid? | ||
|
||
@plugin_data.map do |key, data| | ||
[key, data.merge(query.slice(*RELEVANT_ATTRIBUTES))] | ||
end.to_h | ||
end | ||
|
||
def encoded_target_valid? | ||
CallTool::ChecksumValidator.validate(@query[:target_phone_number], @query[:checksum]) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.