-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapt apology reminder service/job to a new message (#5472)
* exclude message from automated messages page
- Loading branch information
1 parent
de2caca
commit 3eab760
Showing
10 changed files
with
121 additions
and
87 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
class SendDfTransferIssueMessageJob < ApplicationJob | ||
def perform(email: false, sms: false, contact_info: nil, state_code: nil) | ||
message_instance = StateFile::AutomatedMessage::DfTransferIssueMessage.new | ||
|
||
if email | ||
StateFileNotificationEmail.create!( | ||
data_source: nil, # we have no data source because the intakes have been deleted | ||
to: contact_info, | ||
body: message_instance.email_body(state_code: state_code), | ||
subject: message_instance.email_subject(state_code: state_code) | ||
) | ||
end | ||
if sms | ||
StateFileNotificationTextMessage.create!( | ||
data_source: nil, # we have no data source because the intakes have been deleted | ||
to_phone_number: contact_info, | ||
body: message_instance.sms_body(state_code: state_code), | ||
) | ||
end | ||
end | ||
|
||
def priority | ||
PRIORITY_MEDIUM | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
app/models/state_file/automated_message/df_transfer_issue_message.rb
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,27 @@ | ||
module StateFile::AutomatedMessage | ||
class DfTransferIssueMessage < BaseAutomatedMessage | ||
def self.name | ||
'messages.state_file.df_transfer_issue_message'.freeze | ||
end | ||
|
||
def self.after_transition_notification? | ||
false | ||
end | ||
|
||
def self.send_only_once? | ||
true | ||
end | ||
|
||
def sms_body(state_code:) | ||
I18n.t("messages.state_file.df_transfer_issue_message.sms", state_code: state_code) | ||
end | ||
|
||
def email_subject(state_code:) | ||
I18n.t("messages.state_file.df_transfer_issue_message.email.subject", state_name: StateFile::StateInformationService.state_name(state_code)) | ||
end | ||
|
||
def email_body(state_code:) | ||
I18n.t("messages.state_file.df_transfer_issue_message.email.body", state_code: state_code) | ||
end | ||
end | ||
end |
24 changes: 0 additions & 24 deletions
24
app/models/state_file/automated_message/reminder_apology.rb
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
app/services/state_file/send_df_transfer_issue_message_service.rb
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,38 @@ | ||
module StateFile | ||
class SendDfTransferIssueMessageService | ||
# assuming a data structure that looks like this: | ||
# [ | ||
# { | ||
# email: false, | ||
# sms: true, | ||
# contact_info: "5551112222", | ||
# state_code: "az" | ||
# } | ||
# ] | ||
# and that the client verified and opted in to each of these contact methods | ||
def self.run(contact_list) | ||
contact_list.each_with_index do |contact, i| | ||
puts "." | ||
if !StateFile::StateInformationService.active_state_codes.include?(contact[:state_code]) | ||
puts "state code missing or invalid; index #{i}; #{contact[:contact_info]}" | ||
return | ||
end | ||
if contact[:contact_info].blank? | ||
puts "no contact info; index #{i}; #{contact[:state_code]}" | ||
return | ||
end | ||
if !contact[:email] && !contact[:sms] | ||
puts "no contact method; index #{i}; #{contact[:contact_info]} #{contact[:state_code]}" | ||
return | ||
end | ||
SendDfTransferIssueMessageJob.perform_later( | ||
email: contact[:email], | ||
sms: contact[:sms], | ||
contact_info: contact[:contact_info], | ||
state_code: contact[:state_code] | ||
) | ||
end | ||
end | ||
end | ||
end | ||
|
This file was deleted.
Oops, something went wrong.
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