Skip to content

Commit d54245f

Browse files
committed
Merge remote-tracking branch 'origin/main' into FYST-2219-change-linter-to-standard-rb-with-github-action
2 parents 5a275c8 + df8bfab commit d54245f

40 files changed

Lines changed: 1173 additions & 70 deletions

.env.development

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@
44
# a. "secrets" module: initialize the key-value pair with empty value, then fill out the value for the key via AWS Secrets Manager
55
# b. "web" and "workers" module: in environment_secrets or environment_variables and
66
SSN_HASHING_KEY="development-hash-key"
7+
8+
TWILIO_AUTH_TOKEN="fake_auth_token"
9+
TWILIO_ACCOUNT_SID="fake_account_sid"
10+
TWILIO_MESSAGING_SERVICE="fake_service_sid"

.github/workflows/deploy-to-production.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
release_type:
77
description: 'Part of version to increment (major, minor, patch)'
88
required: true
9-
default: 'patch'
9+
default: 'minor'
1010
type: choice
1111
options: [patch, minor, major]
1212
release_title:
@@ -120,7 +120,7 @@ jobs:
120120
echo "EOF" >> $GITHUB_OUTPUT
121121
122122
- name: Notify Slack
123-
uses: slackapi/slack-github-action@v1.24.0
123+
uses: slackapi/slack-github-action@v2.1.1
124124
if: success()
125125
with:
126126
payload: ${{ steps.slack_payload.outputs.payload }}
@@ -203,7 +203,7 @@ jobs:
203203
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
204204

205205
- name: Notify deploy success on Slack
206-
uses: slackapi/slack-github-action@v1.24.0
206+
uses: slackapi/slack-github-action@v2.1.1
207207
if: success()
208208
with:
209209
payload: |

Gemfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ gem "rails", "~> 8.0.2"
66
gem "propshaft"
77
gem "pg"
88
gem "rails-i18n"
9-
gem "valid_email2", "~> 4.0.6"
9+
gem "valid_email2", "~> 7.0.13"
1010
gem "phony"
1111
gem "auto_strip_attributes"
1212
gem "devise"
@@ -24,16 +24,16 @@ gem "stimulus-rails"
2424
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
2525
gem "jbuilder"
2626
gem "cfa-styleguide", "0.17.1", git: "https://github.com/codeforamerica/honeycrisp-gem", branch: "main", ref: "40a4356dd217dacfba82a7b92010111999954c91"
27-
27+
gem "delayed_job_active_record"
28+
gem "delayed_job_web"
2829
# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
2930
# gem "bcrypt", "~> 3.1.7"
3031

3132
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
32-
gem "tzinfo-data", platforms: %i[windows jruby]
33+
gem "tzinfo-data", platforms: %i[ windows jruby ]
3334

3435
# Use the database-backed adapters for Rails.cache, Active Job, and Action Cable
3536
gem "solid_cache"
36-
gem "solid_queue"
3737
gem "solid_cable"
3838

3939
gem "aws-sdk-s3", require: false
@@ -49,7 +49,7 @@ gem "thruster", require: false
4949

5050
group :development, :test do
5151
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
52-
gem "debug", platforms: %i[mri windows], require: "debug/prelude"
52+
gem "debug", platforms: %i[ mri windows ], require: "debug/prelude"
5353

5454
# Static analysis for security vulnerabilities [https://brakemanscanner.org/]
5555
gem "brakeman", require: false
@@ -77,3 +77,4 @@ end
7777

7878
gem "dartsass-rails", "~> 0.5.1"
7979
gem "http_accept_language"
80+
gem "twilio-ruby"

Gemfile.lock

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,16 @@ GEM
145145
debug (1.11.0)
146146
irb (~> 1.10)
147147
reline (>= 0.3.8)
148+
delayed_job (4.1.13)
149+
activesupport (>= 3.0, < 9.0)
150+
delayed_job_active_record (4.1.11)
151+
activerecord (>= 3.0, < 9.0)
152+
delayed_job (>= 3.0, < 5)
153+
delayed_job_web (1.4.4)
154+
activerecord (> 3.0.0)
155+
delayed_job (> 2.0.3)
156+
rack-protection (>= 1.5.5)
157+
sinatra (>= 1.4.4)
148158
devise (4.9.4)
149159
bcrypt (~> 3.0)
150160
orm_adapter (~> 0.1)
@@ -156,8 +166,6 @@ GEM
156166
drb (2.2.3)
157167
erb (5.0.2)
158168
erubi (1.13.1)
159-
et-orbi (1.2.11)
160-
tzinfo
161169
execjs (2.10.0)
162170
factory_bot (6.5.4)
163171
activesupport (>= 6.1.0)
@@ -180,9 +188,6 @@ GEM
180188
ffi (1.17.2-x86_64-darwin)
181189
ffi (1.17.2-x86_64-linux-gnu)
182190
ffi (1.17.2-x86_64-linux-musl)
183-
fugit (1.11.1)
184-
et-orbi (~> 1, >= 1.2.11)
185-
raabro (~> 1.4)
186191
globalid (1.2.1)
187192
activesupport (>= 6.1)
188193
google-protobuf (4.31.1)
@@ -227,6 +232,8 @@ GEM
227232
railties (>= 4.2.0)
228233
thor (>= 0.14, < 2.0)
229234
json (2.13.0)
235+
jwt (2.10.2)
236+
base64
230237
language_server-protocol (3.17.0.5)
231238
lint_roller (1.1.0)
232239
logger (1.7.0)
@@ -253,6 +260,8 @@ GEM
253260
minitest (5.25.5)
254261
msgpack (1.8.0)
255262
multipart-post (2.4.1)
263+
mustermann (3.0.4)
264+
ruby2_keywords (~> 0.0.1)
256265
net-http (0.6.0)
257266
uri
258267
net-imap (0.5.9)
@@ -308,9 +317,12 @@ GEM
308317
public_suffix (6.0.2)
309318
puma (6.6.0)
310319
nio4r (~> 2.0)
311-
raabro (1.4.0)
312320
racc (1.8.1)
313321
rack (3.1.16)
322+
rack-protection (4.1.1)
323+
base64 (>= 0.1.0)
324+
logger (>= 1.6.0)
325+
rack (>= 3.0.0, < 4)
314326
rack-session (2.1.1)
315327
base64 (>= 0.1.0)
316328
rack (>= 3.0.0)
@@ -415,6 +427,7 @@ GEM
415427
rubocop-performance (>= 1.24)
416428
rubocop-rails (>= 2.30)
417429
ruby-progressbar (1.13.0)
430+
ruby2_keywords (0.0.5)
418431
rubyzip (2.4.1)
419432
sass (3.7.4)
420433
sass-listen (~> 4.0.0)
@@ -444,6 +457,13 @@ GEM
444457
rexml (~> 3.2, >= 3.2.5)
445458
rubyzip (>= 1.2.2, < 3.0)
446459
websocket (~> 1.0)
460+
sinatra (4.1.1)
461+
logger (>= 1.6.0)
462+
mustermann (~> 3.0)
463+
rack (>= 3.0.0, < 4)
464+
rack-protection (= 4.1.1)
465+
rack-session (>= 2.0.0, < 3)
466+
tilt (~> 2.0)
447467
solid_cable (3.0.11)
448468
actioncable (>= 7.2)
449469
activejob (>= 7.2)
@@ -453,13 +473,6 @@ GEM
453473
activejob (>= 7.2)
454474
activerecord (>= 7.2)
455475
railties (>= 7.2)
456-
solid_queue (1.2.0)
457-
activejob (>= 7.1)
458-
activerecord (>= 7.1)
459-
concurrent-ruby (>= 1.3.1)
460-
fugit (~> 1.11.0)
461-
railties (>= 7.1)
462-
thor (~> 1.3.1)
463476
standard (1.50.0)
464477
language_server-protocol (~> 3.17.0.2)
465478
lint_roller (~> 1.0)
@@ -481,19 +494,24 @@ GEM
481494
thruster (0.1.14-arm64-darwin)
482495
thruster (0.1.14-x86_64-darwin)
483496
thruster (0.1.14-x86_64-linux)
497+
tilt (2.6.1)
484498
timeout (0.4.3)
485499
turbo-rails (2.0.16)
486500
actionpack (>= 7.1.0)
487501
railties (>= 7.1.0)
502+
twilio-ruby (7.7.0)
503+
faraday (>= 0.9, < 3.0)
504+
jwt (>= 1.5, < 3.0)
505+
nokogiri (>= 1.6, < 2.0)
488506
tzinfo (2.0.6)
489507
concurrent-ruby (~> 1.0)
490508
unicode-display_width (3.1.4)
491509
unicode-emoji (~> 4.0, >= 4.0.4)
492510
unicode-emoji (4.0.4)
493511
uri (1.0.3)
494512
useragent (0.16.11)
495-
valid_email2 (4.0.6)
496-
activemodel (>= 3.2)
513+
valid_email2 (7.0.13)
514+
activemodel (>= 6.0)
497515
mail (~> 2.5)
498516
warden (1.2.9)
499517
rack (>= 2.0.9)
@@ -535,6 +553,8 @@ DEPENDENCIES
535553
cfa-styleguide (= 0.17.1)!
536554
dartsass-rails (~> 0.5.1)
537555
debug
556+
delayed_job_active_record
557+
delayed_job_web
538558
devise
539559
dotenv
540560
factory_bot_rails
@@ -555,13 +575,13 @@ DEPENDENCIES
555575
selenium-webdriver
556576
solid_cable
557577
solid_cache
558-
solid_queue
559578
standard (>= 1.35.1)
560579
stimulus-rails
561580
thruster
562581
turbo-rails
582+
twilio-ruby
563583
tzinfo-data
564-
valid_email2 (~> 4.0.6)
584+
valid_email2 (~> 7.0.13)
565585
web-console
566586

567587
BUNDLED WITH
3.03 KB
Loading

app/controllers/verification_code_controller.rb

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,27 @@ def setup_contact
88
end
99

1010
def edit
11-
@form = VerificationCodeForm.new(contact_info: @contact_info)
11+
@form = VerificationCodeForm.new(contact_info: @contact_info, contact_preference: current_archived_intake.contact_preference)
1212
case current_archived_intake.contact_preference
1313
when "text"
14-
# @phone_number = current_archived_intake.phone_number
15-
# ArchivedIntakeTextVerificationCodeJob.perform_later(
16-
# phone_number: @phone_number,
17-
# locale: I18n.locale
18-
# )
14+
@phone_number = current_archived_intake.phone_number
15+
TextMessageVerificationCodeJob.perform_later(
16+
phone_number: @phone_number,
17+
locale: I18n.locale
18+
)
1919
when "email"
20-
# @email_address = current_archived_intake.email_address
21-
# ArchivedIntakeEmailVerificationCodeJob.perform_later(
22-
# email_address: @email_address,
23-
# locale: I18n.locale
24-
# )
20+
@email_address = current_archived_intake.email_address
21+
EmailVerificationCodeJob.perform_later(
22+
email_address: @email_address,
23+
locale: I18n.locale
24+
)
2525
else
2626
redirect_to root_path
2727
end
2828
end
2929

3030
def update
31-
@form = VerificationCodeForm.new(verification_code_form_params, contact_info: current_archived_intake.contact)
32-
31+
@form = VerificationCodeForm.new(verification_code_form_params, contact_info: current_archived_intake.contact, contact_preference: current_archived_intake.contact_preference)
3332
if @form.valid?
3433
# standard:disable Style/IdenticalConditionalBranches
3534
case current_archived_intake.contact_preference
Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
class VerificationCodeForm < Form
2-
attr_accessor :verification_code, :contact_info
2+
attr_accessor :verification_code, :contact_info, :contact_preference
33

44
validates :verification_code, presence: true
5-
def initialize(attributes = {}, contact_info: nil)
5+
def initialize(attributes = {}, contact_info: nil, contact_preference: nil)
66
super(attributes)
77
@contact_info = contact_info
8+
@contact_preference = contact_preference
89
end
910

1011
def valid?
1112
return true if Rails.configuration.allow_magic_verification_code && verification_code == "000000"
1213

13-
# hashed_verification_code = VerificationCodeService.hash_verification_code_with_contact_info(@email_address, verification_code)
14-
#
15-
# valid_code = EmailAccessToken.lookup(hashed_verification_code).exists?
16-
17-
valid_code = nil
14+
hashed_verification_code = VerificationCodeService.hash_verification_code_with_contact_info(@contact_info, verification_code)
15+
valid_code = case contact_preference
16+
when "text"
17+
TextMessageAccessToken.lookup(hashed_verification_code).exists?
18+
when "email"
19+
EmailAccessToken.lookup(hashed_verification_code).exists?
20+
else
21+
false
22+
end
1823

1924
errors.add(:verification_code, I18n.t("errors.attributes.verification_code.invalid")) unless valid_code
20-
2125
valid_code.present?
2226
end
2327
end

app/jobs/application_job.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
class ApplicationJob < ActiveJob::Base
2+
PRIORITY_HIGH = 10
3+
PRIORITY_MEDIUM = 50
4+
PRIORITY_LOW = 100
25
# Automatically retry jobs that encountered a deadlock
36
# retry_on ActiveRecord::Deadlocked
47

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class EmailVerificationCodeJob < ApplicationJob
2+
retry_on Mailgun::CommunicationError
3+
4+
def perform(email_address:, locale:)
5+
EmailVerificationCodeService.request_code(
6+
email_address: email_address,
7+
locale: locale
8+
)
9+
10+
Rails.logger.info "[EmailVerificationCodeJob] Successfully completed for: #{email_address}"
11+
rescue => e
12+
Rails.logger.error "[EmailVerificationCodeJob] Failed for: #{email_address} — Error: #{e.class} - #{e.message}"
13+
raise
14+
end
15+
16+
def priority
17+
PRIORITY_HIGH - 1 # Subtracting one to push to the top of the queue
18+
end
19+
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class TextMessageVerificationCodeJob < ApplicationJob
2+
def perform(phone_number:, locale:)
3+
TextMessageVerificationCodeService.request_code(
4+
phone_number: phone_number,
5+
locale: locale
6+
)
7+
8+
Rails.logger.info "[TextMessageVerificationCodeJob] Successfully completed for: #{phone_number}"
9+
rescue => e
10+
Rails.logger.error "[TextMessageVerificationCodeJob] Failed for: #{phone_number} — Error: #{e.class} - #{e.message}"
11+
raise
12+
end
13+
14+
def priority
15+
PRIORITY_HIGH - 1 # Subtracting one to push to the top of the queue
16+
end
17+
end

0 commit comments

Comments
 (0)